Error = find: -exec: no terminating “;” or “+”


Question or issue on macOS:

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

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

How to solve this problem?

Solution no. 1:

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/ \;

Solution no. 2:

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.

Hope this helps!