Computing.Net > Forums > Programming > csh script: listing files & dir

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

csh script: listing files & dir

Reply to Message Icon

Name: matt_sti (by lil_sti)
Date: November 21, 2006 at 21:17:51 Pacific
OS: UNIX
CPU/Ram: 256MB
Product: SUN
Comment:

I am trying to create a script in UNIX that will list the files in the current directory. Also, if there is a another directory within the current directory it will list its contents. I am fairly new to csh. I was able to get the first part where the contents of the current directory is printed. I am having trouble with how to go to the next directory and print its contents.

Here is a sample of what I have so far:

foreach file (*)
if (-d $file) then
echo $file "(directory)"
else if (-e $file) then
echo $file "(file)"
end

The output would look something like this:

a(file)
b(directory)
c(file)



Sponsored Link
Ads by Google

Response Number 1
Name: wizard-fred
Date: November 22, 2006 at 01:38:34 Pacific
Reply:

Have you tried 'ls' list directory? I don't have my Linux/UNIX computer up, but I seem to rememember that there is an equivalent to the DOS command 'dir /s'. I use to pipe it to a file for further examination.


0
Reply to Message Icon

Related Posts

See More


Visual J# 2005 and Java ? busy tone detection



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: csh script: listing files & dir

Batch Coding - dir list & file exec www.computing.net/answers/programming/batch-coding-dir-list-amp-file-exec/13530.html

listing files in directories www.computing.net/answers/programming/listing-files-in-directories/11071.html

batch list files of dir+user choice www.computing.net/answers/programming/batch-list-files-of-diruser-choice/16683.html