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

Related articles

Andrew Fletcher16 Jan 2025
get IP address from terminal OSX
When troubleshooting network issues or configuring devices, knowing your IP address can be essential. Whether you're connected via Wi-Fi, Ethernet, or tethering through a mobile provider, macOS offers powerful built-in tools to quickly identify your IP address. Here's a practical guide tailored to...