Computing.Net > Forums > Unix > Korn script to find file

Korn script to find file

Reply to Message Icon

Original Message
Name: Bill Dudek
Date: August 29, 2002 at 12:14:57 Pacific
Subject: Korn script to find file
Comment:

I need to write a script to determine if a file exists, I have tried several examples and am getting back unexpected results. I tried an example from abother post and encountered the same problems. When I try to use the test functionality to determine if a file exists, instead it tries to execute the file. This seems to happen regardless of which flag I use for the test -f -w -r. I am running this thorugh the Korn shell on an AIX box. Any help would be greatly appreciated. below is the source code.

semaphorefile= "/u/emp/x1859/list.txt"

if [ -f ${semaphorefile} ]
then
echo "file found"
else
echo "no file"
fi



Report Offensive Message For Removal

Response Number 1
Name: Ned
Date: August 29, 2002 at 12:43:17 Pacific
Subject: Korn script to find file
Reply: (edit)

Remove a space between = and " from the line below.

semaphorefile= "/u/emp/x1859/list.txt"


Report Offensive Follow Up For Removal

Response Number 2
Name: m.ruf
Date: August 30, 2002 at 15:14:12 Pacific
Subject: Korn script to find file
Reply: (edit)

use only:
semaphorefile=/u/emp/x1859/list.txt

if [ -f $semaphorefile ]
then ..
else ..
fi


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Korn script to find file

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software