Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to check for a file? 1

Status
Not open for further replies.

jpor

Technical User
Nov 29, 2000
212
GB
Hello Again,

I am wondering if anyone could enlighten me in how I can find out if a file is present within a Korn Shell script?

At the moment I am depending on a remote site to ftp a file over for which then I have a ksh which checks for things like '0' bytes, commas and changing lowercase characters to uppercase etc.. All I need to to is make usre the file is actually available before doing any of this.

The KSH is running on AIX ver 4.3.3 ML9.

Thanks in advance.

( "To become Wise, first you must ask Questions")
 
Method 1
Code:
if [ -f filename ]
then
  echo filename exists
fi
Method 2
Code:
[[ -f filename ]] && echo filename exists



Columb Healy
 
checks for things like '0' bytes
[ -s /path/to/file ] || echo "empty or unreachable"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks Columb. That works for me.



( "To become Wise, first you must ask Questions")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top