05.08.2013 Views

Module 13: Shell Scripts in UNIX - E-Courses

Module 13: Shell Scripts in UNIX - E-Courses

Module 13: Shell Scripts in UNIX - E-Courses

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Operat<strong>in</strong>g Systems Prof. P. C. P. Bhat<br />

Indian Institute of Science Bangalore<br />

Operat<strong>in</strong>g Systems/<strong>Shell</strong> <strong>Scripts</strong> <strong>in</strong> <strong>UNIX</strong> Lecture Notes<br />

# file sh_10.file<br />

# <strong>in</strong> this program we identify directories <strong>in</strong> the current directory<br />

echo "list<strong>in</strong>g all the directories first"<br />

for i <strong>in</strong> *<br />

do<br />

if test -d $i<br />

then echo "$i is a directory"<br />

fi<br />

done<br />

echo "Now list<strong>in</strong>g the files"<br />

for i <strong>in</strong> *<br />

do<br />

if test -f $i<br />

then<br />

echo "$i is a file"<br />

fi<br />

done<br />

echo "f<strong>in</strong>ally the shell files are"<br />

ls | grep sh_<br />

----------------------------------------------------------------------file<br />

sh 11.file<br />

# file sh_11.file<br />

# In this file we learn about the trap command. We will first<br />

# create many files with different names. Later we will remove<br />

# some of these by explicitly trapp<strong>in</strong>g<br />

touch rmf1<br />

touch keep1<br />

touch rmf2<br />

touch rmf3<br />

touch keep2<br />

touch rmf4<br />

PCP Bhatt/IISc, Bangalore M<strong>13</strong>/V1/June 04/15

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!