Thursday, June 21, 2018

Write a Shell Script that Accept filename and displays last modification time if file exists, otherwise display appropriate message. - OS

echo -n "Enter name of the file:"
read filename
if [ -f $filename ]
then
echo 'Last modification time is '`ls -lt $filename | tr -s " " "," | cut -d "," -f7`
else
echo "File not exist"
fi

No comments:

Post a Comment