2012-09-18

Bash Shell: Check if a file exists

To check, whether a file exists use this expression:

First, create the file thisFileExists.txt:
touch thisFileExists.txt

Now, check if it exists:
if [ -f thisFileExists.txt ]
then
  echo It is there
fi

This is what it looks like in terminal:

No comments:

Post a Comment