Linux command find and exec federated use

Source: Internet
Author: User

The shell's built-in command exec does not start the new shell, but instead uses the command to be executed to replace the current shell process and to clean up the old process's environment, and the other commands after the EXEC command will no longer execute. So, if you are in a shell and execute exec LS then, when the current directory is listed, the shell exits itself because the shell process has been replaced by a process that simply executes the LS command, and the execution ends naturally. exec must take \; End. exec is followed by a level two execution command.

An option for the Find command, as follows: (1) in the current directory (including subdirectories), find all txt files and find the line containing the string "bin" find./-name "*.txt"-exec grep "bin" {} \;

(2) in the current directory (including subdirectories), find the log file 10 days before the find./-name ". Log"-mtime +10-exec ls {} \; ({} and \; there are spaces, \ and; there are no spaces between them, they are connected)

(3) in the current directory (including subdirectories), delete the log of the 10 days ago find./-name ". Log"-mtime +10-exec rm {} \;

(4) in the current directory (including subdirectories), delete all txt files find./-name "*.txt"-exec rm {} \;

Linux command find and exec federated use

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.