Showing posts with label 1study. Show all posts
Showing posts with label 1study. Show all posts

Sunday, 10 August 2014

Robert Sebesta Web technology text book




https://www.dropbox.com/s/n68k0y135s86e0o/Programming%20the%20World-Wide%20Web-Sebesta%20Robert.rar

Write a shell script that takes a valid directory name as an argument and recursively descend all the subdirectories, finds the maximum length of any file in that hierarchy and writes this maximum value to the standard output.


if [ $# -ne 1 ]
then
echo "No argument"
exit
fi
if [ ! -e $1 ]
then
echo "The given directory does not exist"
exit
fi
echo "The file with maximum length $1 dir is"
ls -lR $1|tr -s " "|cut -d " " -f 5,10|sort -n|tail -n 1

Write a shell script that accepts two file names as arguments, checks if the permissions for these files are identical and if the permissions are identical, output common permissions and otherwise output each file name followed by its permissions.


if [ $# -ne 2 ]
then
echo "No arguments"
elif [ ! -e $1 -o ! -e $2 ]
then
echo "FIle does not exist"
else
p1=`ls -l $1|cut -c2-10`
p2=`ls -l $2|cut -c2-10`
if [ $p1 == $p2 ]
then
echo "File permissions are equal & is $p1"
else
echo "File permissions are not equal"
echo "1st file $p1"
echo "2nd file $p2"
fi
fi

 
- |