Shell-find error parsing, shell-find 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