sajad torkamani

Check if file exists:

if [ -f /tmp/foo.txt ]; then
    echo "File found!"
fi

Check if file doesn’t exist:

if [ ! -f /tmp/foo.txt ]; then
    echo "File not found!"
fi
Tagged: Bash

Leave a comment

Your email address will not be published. Required fields are marked *