How to Improve find Performance

Source: Internet
Author: User
  • 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.