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

Try this with GNU find:

echo "File Name,Modified Date"; find . -name '*.csv' -printf "%f,%TY-%Tm-%Td %TI:%TM\n"
  • 1
    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 '15 at 9:41
  • 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 '15 at 9:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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