Shell-find Error parsing

Source: Internet
Author: User

Previously wrote an article, with Shell timed purge expired files "Shell timed purge expired files", its practical is simple find command

After the colleague adopted, he debug the script, there are a few errors, I did the collation:

1.find:paths must precede expression:exec

The expression is incomplete, and an execute symbol "-" is added before exec.

2.find:missing argument to '-exec '

According to the hint, the wrong parameter-exec is actually a hint that you have an expression error.

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

Workaround: Add a space in front of \ to pay special attention to

Solve the idea, first go to man find, just have find .-type f-exec file ' {} ';

This explanation is clear enough: Runs ' file ' on every file in or below the current directory.  Notice that the braces is enclosed in a 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 could has been used in this case Also.

--not to be continued

Shell-find Error parsing

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