I am trying to decipher a script and one of the lines reads like this:
if [ -f "${DBPATH}.db" ] ; then
Can anyone tell me what the -f does?
Thanks,
Melissa
I am trying to decipher a script and one of the lines reads like this:
if [ -f "${DBPATH}.db" ] ; then
Can anyone tell me what the -f does?
Thanks,
Melissa
it's the same as test -f, which checks to see if a file exist and is a reqular file
Thankyou.
When I was trying to find these conditional tests, I was finding it very difficult to locate any of these.
Hopefully this list will help for BASH shell users.
Usage:
if [ switch variable ]
eg:
if [ -e "$filename" ]; then
do
something.....
done
where switch and variable are one of the following:
switch variable
-n <variable> tests for non-empty variable
-e <filename> test for existence of file
-L <filename> tests if file is a link to another file
-f <filename> tests if is a regular file
-z <variable> tests if variable is empty
-d <directory> tests for existence of directory
-eq used instead of = (equal)
-neq used instead of != (not equal)
-lt used instead of < (less than)
-gt used instead of > (greater than)
-ge used instead of >= (greater than or equal)
-le used instead of <= (less than or equal)
hope this helps somebody....