11

This question is quite similar to How can I list files with their absolute path in linux?

I want to get the name of file or folder with absolute path and date modified.

This command almost does it:

ls -lR /foo/bar | awk '{print $6,$7,$8,$9}'

But it doesnt show the absolute path.

Regards Stollan

Community
  • 1
  • 1
Stollan
  • 113
  • 1
  • 1
  • 4

3 Answers3

13

Check out the find command and its printf option.

find /foo/bar -printf "%p %A@"

See the man page of find for more information.

Benjamin W.
  • 46,058
  • 19
  • 106
  • 116
ghostdog74
  • 327,991
  • 56
  • 259
  • 343
  • 2
    `find /directory -name "hello" -type f -print -exec date -r {} +%Y/%D:%H:%M \;` another way, won't give it as answer because yours is good. – Anders Jul 26 '10 at 14:06
  • 1
    You might want a `\n`. `%A` is access time - the OP asked for modified time which is `%T`. The `@` gives seconds since the epoch. If you want a more human-readable date/time, use: `%T+` or `%TY-%Tm-%Td %TX` or similar. I'd put the date first for easier fixed-width parsing. So, finally: `find /foo/bar -printf "%TY-%Tm-%Td %TX\t%p\n"` – Dennis Williamson Jul 26 '10 at 14:46
-1

I like to use:

ls -d -1 $PWD/**
Dan Mantyla
  • 1,840
  • 1
  • 22
  • 33
  • True I guess. So only use this if you don't want to include files in directories inside the current directory. – Dan Mantyla Jun 03 '15 at 18:02
  • this is exactly answer I was looking for... well, the /** part, in my case ls -lahrt /logdir1/** /logdir2/** - show hidden [a], human size [h], show modified on bottom [rt - reverse time] – Tom St May 18 '20 at 12:48
-1

After reading some partial solutions no recursion, partial date format, no pipe... my proposition is from the target folder:

find . -type f -exec ls -lAoUtTh {} \; | awk '{print $9"\t"$5"\/"$6"\/"$8"\t"$7"\t"$4}' | grep -E -i '.*\.fcp\b|.*\.omf\b'

Works well thanks to contributors but very slowly basicly me.

Gilles

OsX Darwin 10.8 bash