The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 06-12-2007
igandu igandu is offline
Registered User
 

Join Date: May 2006
Location: Hyderabad, India
Posts: 12
Checking the existence of a file..

Hi,

I am trying to check for the existence of a file using the 'test' and the file existence options.
When trying to check for a file with a space in between e.g 'Team List', it gives the following error.

learn1: line 3: test: `Team: binary operator expected

I am pasting my code below as well:

echo "Please enter a file name"
read fname
if test -f $fname
then
echo "$fname exists"
else
echo "$fname doesnot exist"
fi


Can someone help me with this...

Regards,
Indra
Reply With Quote
Remove advertisements
!!
Forum Sponsor