The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Advanced I/O thangappan UNIX for Advanced & Expert Users 1 04-22-2008 08:10 PM
Advanced LS? bostonrobot UNIX for Dummies Questions & Answers 2 06-10-2007 12:44 PM
Advanced Getopts stefan_hery Shell Programming and Scripting 2 05-08-2005 06:16 PM
Advanced For loop petrk1 Shell Programming and Scripting 9 03-02-2005 02:34 AM
Recursive directory listing without listing files psingh UNIX for Dummies Questions & Answers 4 05-10-2002 07:52 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 08-21-2006
Registered User
 

Join Date: Aug 2006
Posts: 1
advanced dir listing

Hi

i know this Q might seem retarded... yet, i can't find a solution.

i need a bash script that recursively prints like this:

mydir/
myfile1 114 06 Aug 2006
myfile2 234 14 Jun 2006
mydir/mysubdir1/
myfile3 32 18 Feb 2006
mydir/mysubdir1/mysubsubdir1/
myfile4 5324 06 Aug 2006

it looks SO easy...

thx in advance!!
Reply With Quote
Forum Sponsor
  #2  
Old 08-21-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,297
start with find, add an "ls" command with options that you want like this
Code:
find /mydir -print -exec ls [add ls options here] {} \;
If you need to rearrange the output consider awk like this:
(example of swapping say col 4 and col 6 and not printing col 5)
Code:
find /mydir -print -exec ls -l {} \; | awk '{ print $1, $2, $3, $6, $4}'
Reply With Quote
  #3  
Old 08-21-2006
Playing with Ubuntu Now!
 

Join Date: Oct 2005
Location: Chennai
Posts: 364
using find with find

Code:
find $dirname -type d -print 2>/dev/null | while read nam
do
echo $nam\/ 
cd $nam
find . \( ! -name . -prune \) -type f -exec ls -l {} \; |awk '{n=split($9,a,"/"); print a[n],$5,$6,$7,$8}'
done
Used 'cd' as I was not able to avoid listing files in subdirectories.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:12 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0