Searching and executing with find(1)
This afternoon I was faced with searching a directory tree for large files that have rotated within the last 24 hours - a symptom of a problem we were experiencing with a service.
Here’s what I put together quickly:
# find -iname name-\*.log -mtime 0 -exec du -sh {} \;
Explanation of the switches (from the find man page):
-iname pattern
Base of file name (the path with the leading directories removed) matches case insensitive shell pattern pattern
-mtime n
data was last modified n*24 hours ago.
-exec command {} \;
run the specified command on the matched files
It’s not complex (and probably not post-worthy,) but someone may find it helpful.
Tags: Linux