Skip to main content

I needed the check if a file existed in a directory as the migrate script wasn't recognising the file.  To check if a file exists:

FILE={your-directory-path}
if test -f "$FILE"; then
    echo "$FILE exists."
fi

 

If your directory path is /Users/{your name}/Sites/migrate/local_dest_dir/fish/../media/apple-store.png

FILE=/Users/{your name}/Sites/migrate/local_dest_dir/fish/../media/apple-store.png
if test -f "$FILE"; then
    echo "$FILE exists."
fi