Home Man
Search
Today's Posts
Register

This forum is closed for new posts. Please post beginner questions to learn unix and learn linux in the UNIX for Beginners Questions & Answers forum.

List Files Recursively

Tags
beginners

 

 
Thread Tools Search this Thread
# 1  
Old 06-20-2002
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??
# 2  
Old 06-20-2002
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.


# 3  
Old 06-20-2002
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
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 06:45 AM..
# 5  
Old 06-21-2002
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.
# 6  
Old 06-23-2002
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.
# 7  
Old 06-24-2002
Oh man!!

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

typing "ksh"
bash: ksh: command not found

I got no clue!!
 

« Previous Thread | Next 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
Copy files recursively pinklemon UNIX for Dummies Questions & Answers 6 08-02-2014 03:51 PM
Search files recursively ravisingh Linux 1 03-08-2013 10:44 AM
How to recursively search for a list of keywords in a given directory? neelmani Shell Programming and Scripting 4 05-15-2012 10:48 AM
Recursively rename some files mail4mz Shell Programming and Scripting 2 07-12-2011 10:24 PM
Recursively move directories along with files/specific files frintocf Shell Programming and Scripting 8 05-24-2011 07:04 AM
List directories and sub directories recursively excluding files pointers UNIX for Dummies Questions & Answers 3 02-23-2011 08: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 08:23 AM
Need help in moving files recursively jagadish_gaddam UNIX for Dummies Questions & Answers 1 07-06-2010 11:56 AM
ls command to list recursively ONLY subdirectories HLee1981 UNIX for Dummies Questions & Answers 5 05-14-2009 02:19 AM
recursively renaming files catgovind UNIX for Dummies Questions & Answers 2 08-20-2008 02:50 AM


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

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password