Bash: Check if file exists
26 July 2024 (Updated 26 July 2024)
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
Thanks for your comment 🙏. Once it's approved, it will appear here.
Leave a comment