Thursday, August 15, 2019

Shell Scripting

Shell Scripting She-bang

The sign #! is called she-bang and is written at top of the script. It passes instruction to program /bin/sh.
To run your script in a certain shell (shell should be supported by your system), start your script with #! followed by the shell name.

#!/bin/bash
# My first script
echo "Hello World!"

=========================
script 2:- 

#! /bin/bash
echo "Hello $USER"
echo "Hey i am" $USER "and will be telling you about the current processes"
echo "Running processes List"
ps

output:-

Hello 
Hey i am and will be telling you about the current processes
Running processes List
  PID TTY          TIME CMD
    1 ?        00:00:00 timeout
    7 ?        00:00:00 bash
    8 ?        00:00:00 time
   14 ?        00:00:00 bash
   15 ?        00:00:00 ps


=================================================

script 3:-

#! /bin/bash
echo "Hey what's Your First Name?";
read a;
echo "welcome Mr./Mrs. $a, would you like to tell us, Your Last Name";
read b;
echo "Thanks Mr./Mrs. $a $b for telling us your name";
echo "*******************"
echo "Mr./Mrs. $b, it's time to say you good bye"

output:-
Hey what's Your First Name?
welcome Mr./Mrs. Krishna, would you like to tell us, Your Last Name
Thanks Mr./Mrs. Krishna Karra for telling us your name
*******************
Mr./Mrs. Karra, it's time to say you good bye

jdoodle.sh: line 2: $'\r': command not found
jdoodle.sh: line 3: $'\r': command not found
jdoodle.sh: line 4: $'\r': command not found
jdoodle.sh: line 5: $'\r': command not found
jdoodle.sh: line 6: $'\r': command not found

=============================================

sript 4:-


No comments:

Post a Comment