The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM



Thread: Recursive FTP
View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 03-08-2001
mib mib is offline
Registered User
 

Join Date: Jan 2001
Location: Calicut
Posts: 228
use test

example:
Perform a mkdir if a directory does not exist:
test ! -d tempdir && mkdir tempdir

for i in *
do
if test -d "$i"
Directory processing commands......
fi
done


it is commonly used with if while do etc. in shell scripts.

-r filename True if filename exists and is readable
-w filename True if filename exists and is writable
-x filename True if filename exists and is executable
-f filename True if filename exists and is a regular file
-d filename True if filename exists and is a directory
-h filename True if filename exists and is a symbolic link.
...........

test commands returns a status of 0(true) or 1 (false) depending on the evaluation of the conditional expression, which can be unary or binary. there is a long list of expression available; check the man page for more info