Newsgroups: comp.unix.shell Date: Tue, 05 Dec 2006 21:10:38 +0100
> I get "find: missing argument to `-exec'" for the following command but I > don't know how to fix: > > find /other/path ! -group grp -exec ln -s {} dest +
Most implementations of ` require it to immediately follow the {}
Otherwise, use \; rather than `
Michael Tosch
find /other/path ! -group grp -exec sh -c ' exec ln -s "$@" dest' arg0 {} +
Stephane CHAZELAS
> > find /other/path ! -group grp -exec sh -c ' > > exec ln -s "$@" dest' arg0 {} + > > what the arg0 here for?
When using the -c option to the shell, the first argument after the command string is used as the shell's $0, and the remaining ones fill in $@. So you need a dummy argument to fill in $0.
A better question would be what the exec is for. Most shells automatically exec the last (in this case only) command, kind of like tail-call elimination in Scheme. Notice:
$ sh -c 'sleep 10; echo ok' & [17] 32501
$ ps -p 32501 PID TTY TIME CMD 32501 pts/0 00:00:00 sh
barmar $ sh -c 'sleep 100' & [1] 6370 barmar $ ps -p 6370 PID TT STAT TIME COMMAND 6370 p1 S 0:00.02 sleep 100
Barry Margolin
> A better question would be what the exec is for. Most shells > automatically exec the last (in this case only) command, kind of like > tail-call elimination in Scheme. Notice:
ash and pdksh based shells don't, AT&T ksh, bash and zsh based ones do.
If you've got traps set up, that optimisation becomes a bug, such as in AT&T ksh. bash and zsh know not to do that optimisation when there are traps.
Stephane CHAZELAS