I\'ve used the following script to see if a file exists:
#!/bin/bash
FILE=$1
if [ -f $FILE ]; then
echo \"File $FILE exists.\"
else
echo \"File $
You can do this:
[[ ! -f "$FILE" ]] && echo "File doesn't exist"
or
if [[ ! -f "$FILE" ]]; then
echo "File doesn't exist"
fi
If you want to check for file and folder both, then use -e
option instead of -f
. -e
returns true for regular files, directories, socket, character special files, block special files etc.