How do I print file size, file name and modified date with header.Till now I have come up with:

find . -regex '.*\.csv' -execdir stat --printf '%n,%y,%s' {} \;

How to add header and do not print path rather only filename?

File Name,Modified Date
Apple,2015-01-05 12:13
  • You choice of stat is good. Use something like: stat -c "%y %8s %n" -- * | cut -c 1-19,36- | sort -nr
    – dhm
    Jan 24 at 13:27

2 Answers 2


Try this with GNU find:

echo "File Name,Modified Date"; find . -name '*.csv' -printf "%f,%TY-%Tm-%Td %TI:%TM\n"
  • 2
    can you add how this command works. specially the printf part and how does it differ from mine --print and use of exec for each file.
    – kinkajou
    Apr 11, 2015 at 9:41
  • 1
    Your command runs stat for every found file. This is not necessary because GNU find's builtin -printf can show file's last modification time (with %T) and format it as you want. Please see find's manpage section -printf format with subsections %Tk and %Ak.
    – Cyrus
    Apr 11, 2015 at 9:59
fd "<regex>" "<dir>" --exec find {} -printf "%T@ %Td-%Tb-%TY %TT %p\n" |
 sort -n | cut -d " " -f 2-
  • 1
    What is the fd command?
    – Jeff Schaller
    Jan 24 at 11:14
  • What @JeffSchaller wrote! Is it be a typo ? And should we just read find instead ?
    – MC68020
    Jan 24 at 12:43
  • 1
    Probably this. It’s not clear to me whether combining fd and find is significantly better than using find directly... Jan 25 at 9:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .