FIND - Exec

From Wiki.IT-Arts.net
Revision as of 10:05, 9 June 2024 by Admin (talk | contribs) (Created page with "Category:Post-It == grep --help == The basic syntax to execute find with exec : <nowiki> find [path] [arguments] -exec [command] {} \;</nowiki> === List Files === <nowiki> find /home/user/ -type f -name *.txt -exec ls -l {} \;</nowiki> === Remove By Size === Files larger than 500 MB : <nowiki> find /home/user/ -size +500M -exec rm {} \;</nowiki> === Remove By Date === Files older than 10 days <nowiki> find /home/user/ -type f -mtime +10 -exec r...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)



grep --help

The basic syntax to execute find with exec :

find [path] [arguments] -exec [command] {} \;


List Files

find /home/user/ -type f -name *.txt -exec ls -l {} \;


Remove By Size

Files larger than 500 MB :

find /home/user/ -size +500M -exec rm {} \;


Remove By Date

Files older than 10 days

find /home/user/ -type f -mtime +10 -exec rm {} \;

- mtime n -- File's data was last modified less than, more than or exactly n*24 hours ago. See the comments for -atime to understand how rounding affects the interpretation of file modification times.