EN
Bash - check if file exists
5
points
In this short article we would like to show how to check if file exists using Bash and test
command.
Simple solution:
#!/bin/bash
if [ -e "path/to/my/file/or/directory" ]
then
echo "File exists";
fi
Alternative solution
#!/bin/bash
if test -e "path/to/my/file/or/directory"
then
echo "File exists";
fi