|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi,
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 + please . thanks -- Tong (remove underscore(s) to reply) http://xpt.sourceforge.net/ -- Posted via a free Usenet account from http://www.teranews.com |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
* Tong * wrote:
> Hi, > > 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 + > > please . thanks > Most implementations of + require it to immediately follow the {} Otherwise, use \; rather than + You have another problem with the ln command and the static "dest": if find finds two or more files, you will get a "file exists" error. -- Michael Tosch @ hp : com |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
2006-12-05, 21:10(+01), Michael Tosch:
> * Tong * wrote: >> Hi, >> >> 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 + >> >> please . thanks >> > > Most implementations of + require it to immediately follow the {} > Otherwise, use \; rather than + > > You have another problem with the ln command and the static "dest": > if find finds two or more files, you will get a "file exists" error. [...] I think "dest" above is a directory, so you'll get trouble only if find finds two files having the same name. To answer the OP's question find /other/path ! -group grp -exec sh -c ' exec ln -s "$@" dest' arg0 {} + -- Stéphane |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On Tue, 05 Dec 2006 20:16:57 +0000, Stephane CHAZELAS wrote:
>>> 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 + > > find /other/path ! -group grp -exec sh -c ' > exec ln -s "$@" dest' arg0 {} + Thanks for your answers, Stephane. May I ask why the 1st command fails? I tried and succeeded with the following command, which looks not much different than the 1st one: find /other/path ! -group grp -exec chgrp arch {} + why? thanks -- Tong (remove underscore(s) to reply) http://xpt.sourceforge.net/ -- Posted via a free Usenet account from http://www.teranews.com |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
2006-12-05, 17:15(-05), * Tong *:
> On Tue, 05 Dec 2006 20:16:57 +0000, Stephane CHAZELAS wrote: > >>>> 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 + >> >> find /other/path ! -group grp -exec sh -c ' >> exec ln -s "$@" dest' arg0 {} + > > Thanks for your answers, Stephane. > > May I ask why the 1st command fails? [...] As Michael pointed out, + must follow {}. See http://www.opengroup.org/onlinepubs/...ties/find.html -- Stéphane |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
On Tue, 05 Dec 2006 22:25:32 +0000, Stephane CHAZELAS wrote:
>> May I ask why the 1st command fails? > > As Michael pointed out, + must follow {}. Ops, just missed it. thank you both. So basically {} has to be at the end, not like in xargs where it could be anywhere... -- Tong (remove underscore(s) to reply) http://xpt.sourceforge.net/ -- Posted via a free Usenet account from http://www.teranews.com |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
On Tue, 05 Dec 2006 20:16:57 +0000, Stephane CHAZELAS wrote:
> find /other/path ! -group grp -exec sh -c ' > exec ln -s "$@" dest' arg0 {} + what the arg0 here for? (didn't find in 'find' man page.) -- Tong (remove underscore(s) to reply) http://xpt.sourceforge.net/ -- Posted via a free Usenet account from http://www.teranews.com |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
In article <pan.2006.12.05.23.23.29.361706@users.sourceforge. net>,
* Tong * <sun_tong_001@users.sourceforge.net> wrote: > On Tue, 05 Dec 2006 20:16:57 +0000, Stephane CHAZELAS wrote: > > > 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: barmar $ sh -c 'sleep 100' & [1] 6370 barmar $ ps -p 6370 PID TT STAT TIME COMMAND 6370 p1 S 0:00.02 sleep 100 > > (didn't find in 'find' man page.) Why would you expect to find documentation of a sh argument in find's man page? -- Barry Margolin, barmar@alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me *** *** PLEASE don't copy me on replies, I'll read them in the group *** |
|
|
|
#9 |
|
Messages: n/a
Hébergeur: |
2006-12-05, 21:48(-05), Barry Margolin:
> In article <pan.2006.12.05.23.23.29.361706@users.sourceforge. net>, > * Tong * <sun_tong_001@users.sourceforge.net> wrote: > >> On Tue, 05 Dec 2006 20:16:57 +0000, Stephane CHAZELAS wrote: >> >> > 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: 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. -- Stéphane |
|
![]() |
| Outils de la discussion | |
|
|