Tuesday, 21 April 2015

Write a shell script which displays the last modification time if the file exists and a suitable message if it doesn’t.


for var in $@
do
check=`ls -al $var 2>/tmp/err | grep -w $var | cut -d " " -f 9`
if [ "$check" == "$var" ];then
mod_time=`ls -l $var | cut -d " " -f 6,7,8`
echo "***Last modification time of file $var***"
echo "$mod_time"
else
echo "$var file doesnt exists"
fi
done

No comments:
Write comments

Featured post

List of Universities in Karnataka offering M.Sc Computer Science

The post-graduate programme in Computer Science (M.Sc Computer Science) contains two academic years duration and having a four semesters....

Popular Posts

Copyright @ 2011-2016