Sample 1 :Interactive Shell scripts
#SS1
#Usage : SS1
# An Interactive Shell Scripts
echo What is Your name\?
read name
echo Hello $name. Happy Programming.
Instructions : Type the same in an Notepad and save the file with the extension (.sh)
./SS1
SS1:execute permission Denied (By default every file gets created with the permission 666 i.e., rw-rw-rw-).
the next thing that we got to do is
$umask
0022 ( with this we can read and write the file but we can execute it)
$ chmod 744 SS1(with this option we get the read,write,execute option open up for our file).
Sample 2 : Arithmetic in Shell Scripts
#SS2
#Usage : SS2
#Example of Arithmetic Operations
a=20 b=10
echo ‘expr $a + $b’
echo ‘expr $a - $b’
echo ‘exp $a * $b’
echo ‘expr $a /$b’
on execution of this shell scripts we get the following output :
30
10
200
2
Sample 3 : if – then –else – fi statement
#SS3
#usage : SS3
Enter the Source and target file names
read source target
if cp $ source $ target
then
echo file copied successfully
else
echo failed to copy the file
fi
for further Study on the Unix Shell Scripting one can contact us.
No comments :
Post a Comment