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

2

3 Answers 3

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.

2
  • 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
    Commented Jul 26, 2010 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" Commented Jul 26, 2010 at 14:46
-1

I like to use:

ls -d -1 $PWD/**
2
  • True I guess. So only use this if you don't want to include files in directories inside the current directory. Commented Jun 3, 2015 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
    Commented May 18, 2020 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

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