Shell Scripts for beginners


Sample 1 :Interactive Shell scripts


#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: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


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


#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 :






Sample 3 :  if – then –else – fi  statement


#usage : SS3

Enter the Source and target file names

read source target

if cp $ source $ target


echo file copied successfully


echo failed to copy the file


for further Study on the Unix Shell Scripting one can contact us.

No comments :

Post a Comment

Recent Comments