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
|