View Single Post

  #2 (permalink)  
Old 02-08-2008, 12:48 AM
rockdalinux's Avatar
rockdalinux rockdalinux is offline
Contributors
User
 
Join Date: May 2005
Location: Bangalore
My distro: RHEL, HP-UX, Solaris, FreeBSD, Ubuntu
Posts: 581
Rep Power: 7
rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough
Default

Welcome to forum!

Use the -f option

Code:
[ -f /etc/fack.file ] && echo "File exists" || echo "Sorry "
In a shell script:

Code:
if [ -f /path/to/a.txt ]; then
 # file exist do something
 echo "File found"
else
  # file does NOT exist do something like give error
  echo "Error file not found"
fi
__________________
Rocky Jr.
You may have my body & soul, but you will never touch my pride!

If you have knowledge, let others light their candles at it.

Certified to work on HP-UX / Sun Solaris / RedHat
Reply With Quote