List Files Recursively | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


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 !!

List Files Recursively

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 06-20-2002
roberthawke roberthawke is offline
Registered User
 
Join Date: May 2002
Last Activity: 25 June 2002, 4:21 AM EDT
Location: Austria
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
List Files Recursively

Hi!

I'd like to list my files recursively BUT:

I want them in this format, so that I can use them as options for commands like ftp->put or del

./directory1/file1.tar
./directory1/file2.tar
./directory1/file3.tar
./directory2/file1.tar
./directory2/file2.tar
./directory2/file3.tar
./directory2/file4.tar

Is there any option with ls or is there another command to do this??
Sponsored Links
    #2  
Old 06-20-2002
Kelam_Magnus's Avatar
Kelam_Magnus Kelam_Magnus is offline Forum Advisor  
Registered User
 
Join Date: Aug 2001
Last Activity: 18 April 2013, 3:03 PM EDT
Location: San Antonio, TX,
Posts: 1,070
Thanks: 0
Thanked 4 Times in 4 Posts
I beleive that you will need to use wildcards in your search portion of the ls statement.

As follows:

cd /

ls -la /*/* |awk '{ print $NF }' > /path/to/file # $NF will print the last field always so that you can get the filename intact with full path.


This will recursively list down 1 directory from the current directory. However, this will not do subsequent subdirectories. you will need to add a /* for each additional subdirectory and append that to the file you created with previous ls statements.

ls -la /* |awk ... > /path/to/file
ls -la /*/* | awk ... >> /path/to/file # append to first output.
ls -la /*/*/* | awk ... >> /path/to/file # and append again.
etc... ... ...


And the -a option will sort by alpha order as well. It will also pipe throught awk so that only the full path is listed and not file information.

There is another way but it does not show the full path.

ls -Rla |pg

This only shows a directory then the actual filename under that directory, not the full path as you requested.


Sponsored Links
    #3  
Old 06-20-2002
peter.herlihy peter.herlihy is offline
Registered User
 
Join Date: Nov 2001
Last Activity: 1 August 2006, 11:51 AM EDT
Location: New Zealand
Posts: 333
Thanks: 0
Thanked 0 Times in 0 Posts
Just use:

find . -name '*'

This will find all files from the point of execution downwards - and display the filepath and name from that same point.

You can change the fullstop (after find) to be any place in the filesystem....
    #4  
Old 06-21-2002
roberthawke roberthawke is offline
Registered User
 
Join Date: May 2002
Last Activity: 25 June 2002, 4:21 AM EDT
Location: Austria
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
I've got no idea, what the hell is up with that system, however pg and awk and find do not work. It only says:

bash: awk: command not found
bash: pg: command not found
bash: find: command not found

I'm not working on a local unix machine. I use SSH. Could it be that these commands are blocked for SSH??

Or do I probably run the wrong shell

By the way:

man doesn't work either!

Last edited by roberthawke; 06-21-2002 at 07:45 AM..
Sponsored Links
    #5  
Old 06-21-2002
Kelam_Magnus's Avatar
Kelam_Magnus Kelam_Magnus is offline Forum Advisor  
Registered User
 
Join Date: Aug 2001
Last Activity: 18 April 2013, 3:03 PM EDT
Location: San Antonio, TX,
Posts: 1,070
Thanks: 0
Thanked 4 Times in 4 Posts
A few questions.

Unless there are very restrictive, special settings, you should at least be able to use man and find. That is very strange indeed.


Are you root on this session or a normal user?
Is your PATH set to see those directories?


If you want to change your shell just type "ksh" at the prompt. Then type exit to quit the shell. You might check with the SA to see what the settings are for this system.
Sponsored Links
    #6  
Old 06-23-2002
peter.herlihy peter.herlihy is offline
Registered User
 
Join Date: Nov 2001
Last Activity: 1 August 2006, 11:51 AM EDT
Location: New Zealand
Posts: 333
Thanks: 0
Thanked 0 Times in 0 Posts
Quick check to see if they're inyour path...is "which find"

This will tell you where it is - if it's in your path. If it can't find it (which I suspect) then it's not in your path and needs to be added.
Sponsored Links
    #7  
Old 06-24-2002
roberthawke roberthawke is offline
Registered User
 
Join Date: May 2002
Last Activity: 25 June 2002, 4:21 AM EDT
Location: Austria
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Oh man!!

typing "which find"
bash: which: command not found

typing "ksh"
bash: ksh: command not found

I got no clue!!
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to recursively search for a list of keywords in a given directory? neelmani Shell Programming and Scripting 4 05-15-2012 11:48 AM
Recursively move directories along with files/specific files frintocf Shell Programming and Scripting 8 05-24-2011 08:04 AM
List directories and sub directories recursively excluding files pointers UNIX for Dummies Questions & Answers 3 02-23-2011 09:39 PM
How to list all files in dir and sub-dir's recursively along with file size? nmakkena UNIX for Dummies Questions & Answers 3 10-28-2010 09:23 AM
ls command to list recursively ONLY subdirectories HLee1981 UNIX for Dummies Questions & Answers 5 05-14-2009 03:19 AM



All times are GMT -4. The time now is 10:21 AM.