Linux – Find Command Modified Date in Output

linux

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

Best Answer

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.