The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages 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 11:10 PM
Advanced LS? bostonrobot UNIX for Dummies Questions & Answers 2 06-10-2007 03:44 PM
Advanced Getopts stefan_hery Shell Programming and Scripting 2 05-08-2005 09:16 PM
Advanced For loop petrk1 Shell Programming and Scripting 9 03-02-2005 05:34 AM
Recursive directory listing without listing files psingh UNIX for Dummies Questions & Answers 4 05-10-2002 10:52 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-21-2006
xenophobian xenophobian is offline
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!!
  #2 (permalink)  
Old 08-21-2006
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,754
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}'
  #3 (permalink)  
Old 08-21-2006
ranj@chn ranj@chn is offline Forum Advisor  
Playing with Ubuntu Now!
  
 

Join Date: Oct 2005
Location: Chennai
Posts: 365
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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




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


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0