How to check if a file exists in a Linux bash shell script?

You can use test -e option to check if a file exists in a shell script.

If you want to check if a directory exists then use test -id option

Get all the test option using test manual (man test)

Leave a Reply