LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
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, 05: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, 06:38 AM   #2
pan64
Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 5,139

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

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

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


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 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 08:36 PM
Extracting File Names from Long Listing of Directory in UNIX Hi_This_is_Dev Programming 15 09-01-2010 12:32 AM
[SOLVED] How to changing same file names by their directory names? bayaraa_u Linux - General 3 04-09-2010 09:26 AM
diff file to side-by-side comparison saawan Linux - Software 4 03-01-2010 10:00 PM
"catting" files in one file side by side, not among each other indyn00b Programming 5 05-10-2007 02:05 AM


All times are GMT -5. The time now is 06:56 PM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration