[Gllug] Re: spaces and shell scripting
Jon Dye
jon at pecorous.co.uk
Thu Sep 1 14:17:51 UTC 2005
Alain Williams wrote:
> On Thu, Sep 01, 2005 at 02:43:50PM +0100, Jon Dye wrote:
>> # do something with the list of files
>> find /some/directory -print0 | xargs -o some_other_command
>
>
> If you give find '-print0' you must give xargs '--null', or is '-o' supposed
> to be '-0' ?
Oops, that was supposed to be "-0".
>>but I want to avoid multiple find statements because they are slow. I
>>guess I want either to put the list of files in a variable with
>>delimiters between the file names or put them into an array somehow.
>>
>>If any can tell me how to achieve what I want (or suggest a better way
>>to do it) I'd be grateful.
>
> I don't see why you just don't do it using find/xargs:
>
> find /some/directory -print0 | xargs --null --no-run-if-empty some_other_command
>
> --no-run-if-empty stops it doing anything if there is nothing to do.
because I want to run different commands depending on whether there are
one or more files.
JD
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list