Write a Program that takes one or more file/directory names as command line input and reports the following information on the file. A). File type B). Number of links. C). Time of last access. D). Read,Write and Execute permissions.

AIM:

Write  a Program that  takes one or more file/directory names as command line input and reports the following information on the file.                A). File type   B). Number of links.     C).Time of last access.    D).Read,Write and Execute permissions.

Program:

clear
for i in $*
do
if [ -d $i ]
then
echo “Given directory name is found as $i”
fi
if [ -f $i ]
then
echo “Given name is a file as $i “
fi
echo “Type of file/directory $i”
file $i
echo “Last access time is:”
ls -l$i | cut-c 31-46
echo  "no.of links"
ln $i
if [ -x $i –a -w $i-a –r $i ]
then
echo “$i contains all permission”
else
echo “$i does not contain all permissions”
fi
done

Output:

student@ubuntu:~$sh prg12.sh ff1
given name is file ff1
Type of file/directory ff1
last access time
2012-07-07 10:1
No.of links
ff1 does not contain all permissions