advanced dir listing


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting advanced dir listing
# 1  
Old 08-21-2006
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  
Old 08-21-2006
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  
Old 08-21-2006
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Assign read write permission to the user for specific dir and it's sub dir and files in AIX

I have searched this quite a long time but couldn't find the right method for me to use. I need to assign read write permission to the user for specific directories and it's sub directories and files. I do not want to use ACL. I do not want to assign user the same group of that directories too.... (0 Replies)
Discussion started by: blinkingdan
0 Replies

2. UNIX for Beginners Questions & Answers

Listing files with their parent dir?

Hi and good day, This string lets me find the html files: ls -R /Volumes/LC3/Sites/chu | grep "html" But how to list the files with their parent dir 'attached' to them: For example: n/fofo.html n/siso.html m/… / Any assistance would be greatly appreciated! With best regards,... (5 Replies)
Discussion started by: OmarKN
5 Replies

3. UNIX for Dummies Questions & Answers

[Solved] How to remove listing of current user cmd from ps -ef listing?

Hi All, Could you please help to resolve my following issues: Problem Description: Suppose my user name is "MI90". i.e. $USER = MI90 when i run below command, i get all the processes running on the system containing name MQ. ps -ef | grep MQ But sometimes it lists... (8 Replies)
Discussion started by: KDMishra
8 Replies

4. Shell Programming and Scripting

KSH - Find paths of multiple files in CC (dir and sub-dir))

Dear Members, I have a list of xml files like abc.xml.table prq.xml.table ... .. . in a txt file. Now I have to search the file(s) in all directories and sub-directories and print the full path of file in a output txt file. Please help me with the script or command to do so. ... (11 Replies)
Discussion started by: Yoodit
11 Replies

5. UNIX for Dummies Questions & Answers

How to list all files in dir and sub-dir's recursively along with file size?

I am very new to unix as well as shell scripting. I have to write a script for the following requirement. In have to list all the files in directory and its sub directories along with file path and size of the file Please help me in this regard and many thanks in advance. (3 Replies)
Discussion started by: nmakkena
3 Replies

6. Windows & DOS: Issues & Discussions

DOS Dir - listing of full path and timestamp

Hi, (Apologies, I'm sure I'm not the first person to raise this question but so far in my searches haven't found a good answer). I would like to output a listing per line of filename (including full path) and 'last updated' timestamp. e.g: Z:\dir1\file1.txt 01/02/2010 10:43... (5 Replies)
Discussion started by: GM_AIX
5 Replies

7. Shell Programming and Scripting

A script to find dir, delete files in, and then del dir?

Hello!! I have directories from 2008, with files in them. I want to create a script that will find the directoried from 2008 (example directory: drwxr-xr-x 2 isplan users 1024 Nov 21 2008 FILES_112108), delete the files within those directories and then delete the directories... (3 Replies)
Discussion started by: bigben1220
3 Replies

8. UNIX and Linux Applications

CPIO Problem, copy to the root dir / instead of current dir

HI all, I got a CPIO archive that contains a unix filesystem that I try to extract, but it extract to the root dir / unstead of current dir, and happily it detects my file are newer otherwise it would have overwrited my system's file! I tried all these commands cpio -i --make-directories <... (2 Replies)
Discussion started by: nekkro-kvlt
2 Replies

9. UNIX for Dummies Questions & Answers

listing home dir of anothe user

Hi I am trying to display the home directory of another user. I dont have the permissions to change into their directory and wonder is it possible to display their directory eg I cant change directory to john but I am trying to display something like /home/John. If anyone can help I would... (3 Replies)
Discussion started by: mmg2711
3 Replies

10. Shell Programming and Scripting

a script to clone a dir tree, & overwrite the dir struct elsewhere?

hi all, i'm looking for a bash or tcsh script that will clone an empty dir tree 'over' another tree ... specifically, i'd like to: (1) specify a src directory (2) list the directory tree/hiearchy beneath that src dir, w/o files -- just the dirs (3) clone that same, empty dir hierarchy to... (2 Replies)
Discussion started by: OpenMacNews
2 Replies
Login or Register to Ask a Question