Monday, 4 July 2016

PROGRAM TO IMPLEMENT TYPE OF A FILE

echo "Enter file name:"
read fname
if test -f $fname
then
echo "The given name $fname is a file!"
elif test -d $fname
then
echo "The given name $fname is a directory!"
else
  echo “Then name $fname doesn’t exist”
fi
output: 
[csuser@localhost ~]$ vi x
[csuser@localhost ~]$ chmod 777 x
[csuser@localhost ~]$ ./x
Enter file name:
a                                                   ->   (a is a file name)
Then name a doesn.t exist.

No comments:

Post a Comment