Pages

Tuesday, March 19, 2013

Write a script open the given file?

$vi open_file.sh
echo “enter file name:”
read fname
if [ -e $fname ]
then
if [ -f $fname ]
then
if [ -r $fname ]
then
cat $fname
else
chmod u+r $fname
cat $fname
else “it is not a regular file”
else
echo “It is not a regualr file”
else
echo “file doesnt exist”
fi
:wq

No comments:

Post a Comment