Take action based on the presence of a file
To control if the script should run based on if a certain file exists or not you can use the
-e option in a
-e option simply stand for
exist and will return a
false value that is further processed by the
This is 2 ways of many you can do this, in the first example we check if the file exist and decide to do something both on if it returns
False, in some scenarios this is desired but sometimes you just want to check if it do not exist and not execute anything special and just continue with rest of the script as in example 2 when it exists.
!in front of
-ethis changes the check from
not existand eliminated any special actions for
exist, it will of course still execute the rest of the script in this case when the file exists.