Usage of find and xargs ------ Actual Example

Source: Internet
Author: User
Usage of find and xargs ------ actual example -- general Linux technology-Linux programming and kernel information. The following is a detailed description. (1) find.-type f-exec ls-l {}\;
Explanation: Find all common files in the current path and list them.

(2) find logs-type f-mtime + 5-exec rm {}\;
Explanation: delete files updated in the logs directory for more than five days.

(3) find.-name "*. log"-mtime + 5-OK rm {}\;
Explanation: Delete the current path. Files whose names end with logs more than five days must be confirmed before deletion.

(4) find ~ -Type f-perm 4755-print
Explanation: Find the suid bit in the $ HOME directory and print out the file whose property is 755.

Note: In some systems, find will get all the matching files to exec at a time, but some systems impose restrictions on the exec command length and report: "The parameter column is too long", this requires xargs. Xargs is a part of the retrieved files.

(5) find/-type f-print | xargs file
Explanation: xargs test file classification

(6) find.-name "core *"-print | xargs echo "">/tmp/core. log
Explanation: The core File Information Query Result is reported to the core. Log.

(7) find/-type f-print | xargs chmod o-w

(8) find.-name *-print | xargs grep "DBO"

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.