3

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.

6

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
single
single
COMBO

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

1:
correct

2:
correct
  • 1
    +1. No need for quotes, find deals with spaces (and other weirdness) internally. – terdon Jun 18 '14 at 13:18
  • Even on arguments for things? Edit: Just tested it and yeah, it does seem to work without quotes. That's pretty fancy. – Oli Jun 18 '14 at 13:18
  • I know right? I used to quote the darn thing all the time until someone pointed it out to me. – terdon Jun 18 '14 at 13:21
  • Also, -execdir is preferred over -exec for security reasons (see man find). – Sparhawk Jun 18 '14 at 14:36
0

You can use this command.

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

According to the find command manual($man find). there are actions can predefined in find command such as delete, ls.

In addition to the predefined actions, we can also invoke arbitrary commands. The traditional way of doing this is with the -exec action. This action works like this:

-exec command {} ;

where command is the name of a command, {} is a symbolic representation of the current pathname and the semicolon is a required delimiter indicating the end of the command.

Again, since the brace and semicolon characters have special meaning to the shell, they must be quoted or escaped.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.