Centos 7 -> Find: Missing Argument for "-Exec"

Centos 7 -> Find: Missing Argument for "-Exec"

Disclaimer: I am a total Linux amateur. Hi, I am currently setting up a PHPIPAM Server on CentOS 7. I am following this guide: , which tells me to run the command: "

find . -type f -exec chmod 0644 {} ;

When I do so, the message:

find: missing argument for "-exec".

shows up. What can I do to get the command to work?

0

3 Answers

Ordinarily the ; acts as a separator between commands. However, for find -exec it needs to be provided as an actual parameter to the command itself (to indicate where the -exec option ends). To achieve that, it needs to be either quoted or escaped:

-exec ..... \;

-exec ..... ";"

-exec ..... ';'
7

When I do so, the message: 'find: missing argument for "-exec".' shows up

find . -type -exec chmod 0644 {} ;

You are missing a \ before the ; at the end of the line (which is missing in the link you quoted).

In addition, you haven't supplied an argument for -type.

Your command should be:

find . -type f -exec chmod 0644 {} \;

-type c File is of type c as listed below:

b block (buffered) special

c character (unbuffered) special

d directory

p named pipe (FIFO)

f regular file

l symbolic link; this is never true if the -L option or the -follow option is in effect, unless the symbolic link is broken. If you want to search for symbolic links when -L is in effect, use -xtype.

s socket

D door (Solaris)

Source find Man Page - Linux - SS64.com

3

The other answers explain why the problem is happening, but there is another solution to the problem. You can use + instead of \; and then you don't have to worry about escaping the ;. For something like chmod over a large number of files, this will likely be somewhat faster, too. You would run it like this:

find . -type f -exec chmod 0644 {} +

They're not exactly identical, though. With + the find command is passing multiple files as separate arguments to a single invocation of chmod. A lot of programs can handle this just fine, but some can't. If a program you want to pass to -exec needs to take exactly 1 file argument at a time, then you have to use \; instead.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Chloe Bennett
Author

Chloe Bennett

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.