Afficher un message
Vieux 13/03/2008, 19h55   #7
pk
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Multiple shell commands using find's -exec

Stephane CHAZELAS wrote:

>> $ find -exec sh -c "wc -l '{}'; head -n 2 '{}' && tail -n 2 '{}'" \;

> [...]
>
> That's non-standard and dangerous. Standardly, you can only
> expect {} to be expanded to the filename if it consistutes an
> argument of find by itself.
>
> find ... -exec ... {} \; # OK
> find ... -exec ... x{} \; # NOK
>
> find ... -exec sh -c '... "x$1"' {} {} \; # OK
>


Yes, I should have specified GNU find.
Thanks for the correction.
Unfortunately, I can only access linux systems with GNU utilities so my
solutions are always based on what I can use. I'll probably use a signature
to indicate that.

Thanks

  Réponse avec citation
 
Page generated in 0,04325 seconds with 9 queries