The UNIX and Linux Forums  

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


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Recursive FTP -- here at last. Perderabo Shell Programming and Scripting 48 09-08-2008 07:56 AM
Recursive pid script jbarnhar Shell Programming and Scripting 3 05-02-2007 12:14 PM
recursive wc on a directory? bimba17 UNIX for Dummies Questions & Answers 1 11-29-2006 01:05 PM
recursive sorting fermisoft UNIX for Advanced & Expert Users 1 08-16-2005 05:46 AM
recursive rcp Nicol Shell Programming and Scripting 6 11-06-2003 07:52 AM

Closed Thread
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-07-2001
Registered User
 

Join Date: Mar 2001
Location: Birmingham, UK
Posts: 2
Unhappy

I am trying to write a recursive FTP script and have come to a point where I need to test if the file is either a normal ascii file or a directory. My question is how do I test if the file is either ascii or directory.
Forum Sponsor
  #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



Google The UNIX and Linux Forums
Closed Thread

Thread Tools
Display Modes




All times are GMT -7. The time now is 12:12 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0