Shell-find error Parsing

Source: Internet
Author: User

Shell-find error Parsing

I have written an article about how to use shell to regularly clear expired files. In fact, the simple find command is used.

After my colleague adopted the script, he encountered several errors when debugging the script. I sorted it out:

1. find: paths must precede expression: exec

The expression is incomplete. Just add an execution symbol "-" before exec.

2. find: missing argument to '-exec'

According to the prompt, the error parameter-exec actually prompts that your expression is incorrect.

The original statement is "find/var/log/*. log-mtime + 30-exec rm-f {}\;"

Solution:Add a space in front of \. Note that

Solution: Go to man find to find the solution.Find.-type f-exec file '{}'\;

This explanation is clear: Runs 'file' on every file in or below the current directory. notice that the braces are enclosed in single quote marks to protect them from interpretation as shell script punctuation. the semicolon is similarly protected by the use of a backslash, though single quotes cocould have been used in that case also.

-- To be continued

Related Article

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: 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.