Find files that were modified by a given command

touch /tmp/file ; $EXECUTECOMMAND ; find /path -newer /tmp/file
This has helped me numerous times trying to find either log files or tmp files that get created after execution of a command. And really eye opening as to how active a given process really is. Play around with -anewer, -cnewer & -newerXY
Sample Output
[root@localhost ~]# touch /tmp/service
[root@localhost ~]# service cups restart
Stopping cups:                                             [  OK  ]
Starting cups:                                             [  OK  ]
[root@localhost ~]# find /var -newer /tmp/service
/var/cache/cups/job.cache
/var/lock/subsys
/var/lock/subsys/cups
/var/log/audit/audit.log
/var/run
/var/run/cupsd.pid
/var/run/cups
/var/run/cups/cups.sock
/var/run/cups/certs
/var/run/cups/certs/0
[root@localhost ~]#

22
2009-08-31 18:47:19

1 Alternatives + Submit Alt

What Others Think

Great command! Another way could also use strace. strace records all system calls made, and you can even attach it to running processes: strace -o straceoutput.txt $COMMAND also use -p $PID to attach to an already-running program. Also, use ltrace to trace library calls.
bwoodacre · 480 weeks and 6 days ago
Prefer to use lsof -p, see command: diff
zlemini · 450 weeks and 5 days ago
diff <(lsof -p 1234) <(sleep 10; lsof -p 1234)
zlemini · 450 weeks and 5 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: