I want to list recursively all files in given direcotry, with their fullpath and their timestamps. Something like this:

10:30 Dec 10 2010 /tmp/mydir/myfile

I've tryied with:

find . -type f -exec ls -la {} \;

but that don't give me the fullpath.

link|improve this question

29% accept rate
feedback

3 Answers

up vote 1 down vote accepted

And another way to do it if your find doesn't support printf

find . -type f | xargs ls -al | awk -v pwd="$PWD" '{ print $(NF-2), $(NF-1) , pwd substr($(NF), 2)}'

Note This only works as long as there aren't any spaces in the filenames

Output looks like this:

2010-09-29 22:08 /home/nifle/ac.txt
2010-10-04 16:02 /home/nifle/array.sh
2010-10-05 23:32 /home/nifle/b.txt
2010-12-15 16:49 /home/nifle/barcopy/subbar/ghut
2010-12-15 16:48 /home/nifle/bardir/subbar/ghut
2010-09-29 22:16 /home/nifle/foo.gz
2010-09-29 22:16 /home/nifle/foo1.gz

link|improve this answer
1  
As long as there aren't any spaces in the filenames. – Dennis Williamson Jan 3 '11 at 12:07
@Dennis - Ahh, yes you definitely have a point there. – Nifle Jan 3 '11 at 12:10
feedback
find "$PWD" -type f -exec ls -la {} \;

or

find /tmp/mydir -type f -exec ls -la {} \;

Also, instead of -exec, you might want to use -printf "%t %p\n".

link|improve this answer
You can replace $PWD with .. – Dennis Williamson Jan 3 '11 at 12:08
@Dennis Williamson: the command from the question already uses . instead of $PWD and it doesn't give him the full path. – Cristian Ciupitu Jan 3 '11 at 21:09
Ah, sorry, you are correct. – Dennis Williamson Jan 3 '11 at 21:23
feedback

This question on StackOverflow plays around with one part of your question. In order to get what you want, you could try the following:

find $ABSOLUTE_PATH_TO_DIR -ls
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.