Re: automated editing of text files
>>>>> Aéris <aeris@imirhil.fr> writes:
>>>>> Le 17/09/2011 00:40, Bob Proulx a écrit :
[…]
>> * Secondly if the add-pre-nl.sh script handle multiple file
>> arguments then instead of \; use + so that it calls it fewer times
>> with as many file arguments as possible. It will be more efficient
>> that way.
> In this case, I prefere using « xargs » :
> find -type f -name "*.txt" | xargs add-pre-nl.sh
> And if there is space/single-quote/double-quote/new-line in some
> filenames :
> find -type f -name "*.txt" -print0 | xargs -0 add-pre-nl.sh
And to prevent xargs(1) from starting the command if there're no
arguments to pass (IOW, no .txt files found), -r should be used
as well.
Consider, e. g.:
$ find -type f -print0 | xargs -0 -- cat --
vs.:
$ find -type f -print0 | xargs -r0 -- cat --
The former will read stdin if no regular files under the current
directory (a subtle change in behavior of cat(1) when called
without arguments), while the latter won't, and will just
produce no output.
[…]
--
FSF associate member #7257
Reply to: