What are the most useful `find` predicates for operations work?
BeginnerConceptfind, xargs, jq and yq
Answer
find /var/log/app -type f -name '*.log' -mtime +14 # older than 14 days
find / -xdev -type f -size +500M 2>/dev/null # big files, stay on this filesystem
find /srv -type f -perm -o+w # world-writable files
find /home -nouser -o -nogroup # orphaned files
find . -maxdepth 1 -type d -name 'release-*' # do not recurse
find /etc -newer /var/run/last-deploy -type f # changed since a marker
find /tmp -type f -mmin +60 -user www-data # older than 60 minutes
Quote patterns ('*.log') so the shell does not expand them before find sees them.
More on find, xargs, jq and yq
What is the difference between `-exec cmd {} \;`, `-exec cmd {} +` and `-delete`?IntermediateHow does `find` evaluate `-o` (OR) and why do you need parentheses?AdvancedWhat does `xargs` do, and which flags matter?IntermediateWhy is `find | xargs rm` dangerous and what is the safe form?IntermediateWhat is `jq` and what are the filters you use every day?BeginnerHow do you pass shell variables into `jq` safely?Intermediate