For performance reasons, put the-exec operator closer to the back, the better. This can avoid unnecessary processes.
The find Command needs to read each index node in the directory tree it searches for, so it is best to combine multiple contents into a single find command as much as possible. The method is
find . \( -type d -a -exec chmod 771 {} \; \) -o \( -name "*.BAK" -a -exec chmod 600 {} \; \) -o \( -name "*.sh" -a -exec chmod 755 {} \; \) -o \( -name "*.txt" -a -exec chmod 644 {} \; \) -o \
To improve the efficiency of find, you can consider creating your own find database.
Create a find Database
Cdfind.-print | sed "[email protected] ^./@"> ~ /. Fastfinddb # Storage ~ /, And replace it ./
Create cron and run this script regularly to create the find database.
Create a shell script to use this database
Ffind () {egrep "$1 "~ /. Fastfinddb | sed "[email protected] ^ @ $ home/@" # add $ home before the query result}
How to Improve find Performance