1

I m getting error in follwing command

cd /opt/lampp/htdocs/EspoCRM-2.5.2 && find data -type d -exec chmod 775 {}

error:

find: missing argument to `-exec'

3 Answers 3

5

You need to mark your exec as finished with \; Your command would look like:

cd /opt/lampp/htdocs/EspoCRM-2.5.2 && find data -type d -exec chmod 775 {} \;

BTW: You don't need to cd into a dir. find can take a complete path where to search. So

find /opt/lampp/htdocs/EspoCRM-2.5.2/data/ -type d -exec chmod 775 {} \;

should also work as find call.

2
  • still I am getting same error Commented Sep 19, 2014 at 8:13
  • Command is working. Ensure, everything is correct with your path. Commented Sep 19, 2014 at 9:20
3

As others have said, find's -exec needs to be terminated. However I would actually suggest using + instead of \;. This only works for some commands but using + will build and run a much more efficient command.

For example, if you have three files (a, b and c) in a directory and you run find -exec echo {} \; it will execute:

echo a
echo b
echo c

However, if you use find -exec echo {} + it will dynamically select as many arguments as the environment supports (there is a limit) and, like xargs chains them together... So what is actually run is:

echo a b c

As I said before this will only work if your command supports multiple files at a time. chmod is one of this. You can tell by looking at the man chmod page:

SYNOPSIS
       chmod [OPTION]... MODE[,MODE]... FILE...
       chmod [OPTION]... OCTAL-MODE FILE...
       chmod [OPTION]... --reference=RFILE FILE...

The ellipsis on FILE... means it can take more than one file.

So yeah, chaining them all together means we run much fewer instances of chmod which is good because there's quite a large overhead (on small operations like this) for forking out a new command.

In short, using + is faster.

1

You need to end your command with \;

Try this:

cd /opt/lampp/htdocs/EspoCRM-2.5.2 && find data -type d -exec chmod 775 {} \;

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.