File Comparison characters
-e filename true if filename exists [-e/var/log/syslog]
-D filename True if filename is a directory [-d/tmp/mydir]
-F filename True if filename is a regular file [-f/usr/bin/grep]
-L filename True if filename is a symbolic link [-l/usr/bin/grep]
-R filename True if filename is readable [-r/var/log/syslog]
-W filename if filename is writable, true [-w/var/mytmp.txt]
-X filename is true if filename is executable [-l/usr/bin/grep]
Filename1-nt filename2 If filename1 is newer than filename2, then true [/tmp/install/etc/services-nt/etc/services]
Filename1-ot filename2 If filename1 is older than filename2, then true [/boot/bzimage-ot Arch/i386/boot/bzimage]
The folder does not exist and is created
if [!-d "/data/"];thenmkdir/dataelseecho "folder already exists" fi
File exists then delete
if [!-F "/data/filename"];thenecho "file does not exist" Elserm-rf/data/filenamefi
Determine if a folder exists
If [-d '/data/"];thenecho" folder exists "Elseecho" folder does not exist "fi
Determine if a file exists
If [-d '/data/test "];thenecho" file exists "Elseecho" file does not exist "fi
Shell determines whether a folder or file exists