The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 12-27-2003
jayakhanna jayakhanna is offline
Registered User
 

Join Date: Dec 2003
Location: India
Posts: 50
I am really sorry I was just checking the octal value for \n.
Okay any how the program should be like this

echo "Enter answer"
read answer

if [ "$answer" = "" ]
then
echo "You must enter a file name"
exit 1
else
cat $answer
fi


Well from your mail I think your concern is that you want to check whether the particular file exists or not, Am i right. If so then
use the below code after *read answer* in the above code
Code:
if [ ! -s $answer ]
then
     echo "The file does not exist"
     exit 1
fi
Regards
JK

added code tags for readability --oombera

Last edited by oombera; 02-18-2004 at 10:49 PM.