48

I am looking for some help trying to get a command working. I want to find some files only and move them, but when I enter this command:

find /Volumes/NEXSAN/Engine\ Folders/Input/DTO_Proxy/* -type f -mtime +7 -exec mv -v {} /Volumes/NEXSAN/.2BeDeleted4realz/ 

I get this error

find: -exec: no terminating ";" or "+"

I know I probably have it wrong, but I can't figure out what's missing?

3
  • possible duplicate of find: missing argument to -exec Commented Mar 19, 2015 at 21:24
  • 1
    On a tangential note, I made the mistake of using + without {} which produced the same (misleading) error message on OSX 10.6.8. Commented Oct 18, 2015 at 9:11
  • A similar error can occur if the exec command is in quotes. E.g.: find . -name foo -exec "stat {} \;". Commented Jan 17, 2024 at 17:49

2 Answers 2

77

Just terminate the find command with \;, making sure to include the space before the \;.

find /Volumes/NEXSAN/Engine\ Folders/Input/DTO_Proxy/* -type f -mtime +7 -exec mv -v {} /Volumes/NEXSAN/.2BeDeleted4realz/ \; 
Sign up to request clarification or add additional context in comments.

5 Comments

To anyone who comes across this, make sure that there is a space before the terminating "\;", or find will still complain about no terminating ";"
How does one do this for a terminating '+'? I tried "\+" and it didn't work (bash 4.3.46, find isn't telling me it's version !?, it's on osx)
@drevicko It worked for me after adding {}, i.e. -exec mv {} +.
@DavidResnick was a while ago, but... I think I had some command parameters between {} and \+. This is not allowed by find --- I think because of the way it determines when it needs to run multiple commands (due to there being a lot of found files, hence the command line is too long to do in one go).
And we all wonder why unix / linux isn't more widely adopted by regular people...
6

If you want to correct the find command that you had, it should look like this:

find . -name '*.xml' -exec SetFile -t TEXT {} \; 

The *.xml needs to be quoted so it's passed as a parameter to find instead of expanded by the shell. The ; also needs to be escaped so it's passed as part of the parameter to find and not interpreted by the shell.

Keep in mind this will only work for files within the current directory (and subdirectories) and for any new files created, you would need to run the command again.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.