LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 12-08-2006, 03:41 PM   #1
cdog
Member
 
Registered: Dec 2005
Posts: 65

Rep: Reputation: 15
Recursive directories listing


How can I output only the names of the files and directories recursively?
Thanks
 
Old 12-08-2006, 03:51 PM   #2
fordeck
Member
 
Registered: Oct 2006
Location: Utah
Posts: 520

Rep: Reputation: 61
Try this:

Code:
ls -R
 
Old 12-08-2006, 03:58 PM   #3
cdog
Member
 
Registered: Dec 2005
Posts: 65

Original Poster
Rep: Reputation: 15
Thanks fordeck but I only need the names to use them in a script. I don't want paths. Maybe you can point to a scipt that does that?
 
Old 12-08-2006, 04:23 PM   #4
fordeck
Member
 
Registered: Oct 2006
Location: Utah
Posts: 520

Rep: Reputation: 61
Could you tell us alittle more about what your trying to accomplish? Like what are you wanting to do with the list of files? Maybe you could even give some example data to show what you are trying to do?


Regards,
Fordeck
 
Old 12-08-2006, 04:35 PM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
Code:
ls -R|sed '/\//d'
(deletes all lines containing the character "/") (Still need one more filter to delete the empty lines--maybe?)
 
Old 12-08-2006, 04:50 PM   #6
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,245

Rep: Reputation: 121Reputation: 121
find . -print
 
Old 12-08-2006, 05:04 PM   #7
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
Quote:
Originally Posted by Quakeboy02
find . -print
That gives full pathnames--not what OP was looking for (But then I must not speak for him/her)
 
Old 12-08-2006, 05:27 PM   #8
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
Code:
find . |sed 's|.*/||'
 
Old 12-08-2006, 05:32 PM   #9
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,245

Rep: Reputation: 121Reputation: 121
find . |sed 's|.*/||'


The power of the collective! )
 
Old 12-08-2006, 06:29 PM   #10
cdog
Member
 
Registered: Dec 2005
Posts: 65

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by matthewg42
Code:
find . |sed 's|.*/||'
Excellent. Thanks guys.
 
Old 12-08-2006, 06:55 PM   #11
cdog
Member
 
Registered: Dec 2005
Posts: 65

Original Poster
Rep: Reputation: 15
If I want to write a recursive csh script for diretories listing (instead of using find), how would I do it?
 
Old 12-09-2006, 07:04 AM   #12
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
Eugh, don't use csh. If you want to do it with scripts, at least use a borne style shell. csh is horrible for scripting.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] FTP: recursive chmod (separate for directories and files) mgmax Linux - Software 11 01-29-2011 08:06 AM
How to do recursive file delete using specifier (*.tmp) from nested directories? Arodef Linux - General 3 11-11-2009 07:49 AM
Listing all directories only anjanesh Linux - Newbie 5 06-20-2006 03:23 AM
Recursive chmod with different values for files and directories? Z038 Linux - Newbie 2 06-07-2006 08:38 AM
Bash - listing directories tarja Programming 8 12-03-2005 04:03 PM


All times are GMT -5. The time now is 01:33 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration