Checking If A File Or Directory Exists In Bash
Check For Files (multi-line)
Code
if [; then
Check For Files (single line)
Code
if [; then ;
Using an else
Code
if [; then
else
Using the "not" operator
Code
if [; then
Checking For Directories
To check if a directory exists in a shell script you can use the following:
Code
if [; then
Or to check if a directory doesn't exist:
Code
if [; then
Symbolic links can cause issues. See the stack overflow question below for some ways to deal with that