Ubuntu – How to use -exec option in find command

bashcommand linecompilingcompizscripts

I wanna solve some problems in compiz with my brain and hands.

By the way I entered following command to build compiz from source in Ubuntu 12.04

find /opt/compiz-built/share/gconf/schemas -exec gconftool-2 --install-schema-file={};

I referred that command at http://www.brazzi64.net/blog/building-compiz-from-source-in-ubuntu-12-04/

And following message is shown.

How to use -exec option in find command, I guess that it's my mistake.

Best Answer

You're almost there. You need a \; on the end to let find know where the end of the command is.

find /opt/compiz-built/share/gconf/schemas -exec gconftool-2 --install-schema-file={} \;

For commands that can take multiple arguments at a time (eg if you wanted to just stat each filename) you can use \+ instead. This will build a compound argument which can execute a faster because it doesn't fork out for every single file:

find . -exec stat {} \+

That won't work here for your example though.

Just a test harness to highlight that quotes aren't required:

$ mkdir 1 2 1\ 2               # makes three directories
$ touch {1,2}/single           # puts a file in each of the two singles
$ touch 1\ 2/COMBO             # puts a file in the dir with a space
$ find -type d -exec ls {} \;
1  1 2  2

If it wasn't handling quoting for us, we'd see this instead of COMBO: