3

I'm using the find command find /path/on/server -mtime -1 -name '*.js' to get a list of files modified recently but I'd like the output to also have the date the files were modified

3 Answers 3

2

You can use the -printf option to find to print this if you want

find find /path/on/server -mtime -1 -name '*.js' -printf "%h%f %TD\n"
  • %h the leading directories
  • %f the file name
  • %TD the files modification date

the %p format specifier can be used in place of %h%f for the full path.

You get output like

/path/on/server/somefile.ext 05/24/12

There are lots of options to the printf option so you can build any output format you want.

2

You can customise stat to print exactly the information you like:

find /path/on/server -mtime -1 -name '*.js' -exec stat -c "%n: %y" {} \;

The way this works is that find calls stat -c "%n: %y" FILE; for every FILE that it finds in it's search, and stat prints that to your terminal.

This results in something like:

somefile.txt: 2012-06-13 02:11:59.208822237 +0100
1
  • 1
    find has a really handy -printf option
    – user9517
    Jul 5, 2012 at 17:19
0

Like this?

find /path/on/server -mtime -1 -exec ls -l {} \;

You must log in to answer this question.

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