Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Aug 232011

Check if a file exist in Bash Shell


The following script demonstrates how to check if a file exist, using shell (Bash) script


if [ -e test.txt ]
  echo 'The file exists.'
  echo 'The file does not exist.'

 Leave a Reply



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>