What does -f do


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers What does -f do
# 1  
Old 11-30-2001
What does -f do

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
# 2  
Old 11-30-2001
it's the same as test -f, which checks to see if a file exist and is a reqular file
# 3  
Old 11-30-2001
Thankyou.
# 4  
Old 12-03-2001
BASH "if" switches

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....
 
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question