Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question
add comment

3 Answers

up vote 2 down vote accepted

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.

share|improve this answer
add comment

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
share|improve this answer
1  
find has a really handy -printf option –  Iain Jul 5 '12 at 17:19
add comment

Like this?

find /path/on/server -mtime -1 -exec ls -l {} \;
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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