LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-03-2012, 04:24 AM   #1
anon84
LQ Newbie
 
Registered: Apr 2012
Posts: 3

Rep: Reputation: Disabled
Listing file names side by side with directory names


Hi Guys,

I am a novice in Unix and hoping that you will be able to help me out with the following
I have the follwing folder structure :

/work/test/User1/abcd1.txt
/work/test/User1/abcd12.txt
/work/test/User2/abcd21.txt
/work/test/User2/abcd22.txt
/work/test/User3/abcd31.txt
/work/test/User3/abcd32.txt
/work/test/User4/abcd41.txt
/work/test/User4/abcd42.txt
/work/test/User5/abcd51.txt
/work/test/User5/abcd52.txt

I am looking for a single command(not a script) which will produce an output like this:

User1 abcd1.txt
User1 abcd12.txt
User2 abcd21.txt
User2 abcd22.txt
User3 abcd31.txt
User3 abcd32.txt
User4 abcd41.txt
User4 abcd42.txt
User5 abcd51.txt
User4 abcd52.txt

Basically I want to list the directory names side by side with the filenames contained in each. Thanks in advance.
 
Old 04-03-2012, 05:38 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,970

Rep: Reputation: 7334Reputation: 7334Reputation: 7334Reputation: 7334Reputation: 7334Reputation: 7334Reputation: 7334Reputation: 7334Reputation: 7334Reputation: 7334Reputation: 7334
Code:
ls  -1d /work/test/*/* | awk -F/ ' { print $4 " " $5 } '
 
1 members found this post helpful.
Old 04-03-2012, 06:22 AM   #3
anon84
LQ Newbie
 
Registered: Apr 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thanks a lot.. ..
 
Old 04-03-2012, 10:13 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,009

Rep: Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193
Please mark as SOLVED once you have your solution.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
File names listing question Quest ion Programming 4 10-03-2011 07:36 PM
Extracting File Names from Long Listing of Directory in UNIX Hi_This_is_Dev Programming 15 08-31-2010 11:32 PM
[SOLVED] How to changing same file names by their directory names? bayaraa_u Linux - General 3 04-09-2010 08:26 AM
diff file to side-by-side comparison saawan Linux - Software 4 03-01-2010 09:00 PM
"catting" files in one file side by side, not among each other indyn00b Programming 5 05-10-2007 01:05 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:20 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration