1. Find all files from the current directory that has file permission 777
find . -type f -perm 0777
2. Find all files from the current directory that do not have file permission 777
find . -type f ! -perm 0777
3. Find a single file called 'foo.txt' from the current directory and remove that
find . -type f -name "foo.txt" -exec rm -f {} \;
4. Find multiple files with '.txt' extension from the current directory and remove them
find . -type f -name "*.txt" -exec rm -f {} \;
5. Find files in the current directory that has been modified over last 5 days
find . -type f -mtime -5
6. Find files in the current directory that has been modified before last 5 days
find . -type f -mtime +5
7. Find files in the current directory that has been modified last 1 hour
find . -type f -mmin -60
8. Find files in the current directory that has been changed 1 hour ago
find . -type f -cmin +60
9. Find files in the current directory that has been modified exactly at 1 hour ago
find . -type f -mmin 60
10. Find files in the current directory that are larger than 2M
find . -type f -size +2M
11. Find files in the current directory that are smaller than 2M
find . -type f -size -2M
12. Find files in the current directory that are smaller than 3M but larger than 1M
find . -type f -size +1M -size -3M
I was heavily inspired by this blog post: https://www.tecmint.com/35-practical-examples-of-linux-find-command/
Comments
Post a Comment