How to use the test command to check for the existence of files and directories
You can use the test -e command to check for the existence of a file. By connecting them with &&, it is possible to say that the command will be executed only if the file exists.
$ test -e a.txt && cat a.txt
The existence of the directory is checked with the test -d command.
$ test -d dd && ls -l dd
In addition, it seems to be able to check symbolic links and empty files.