Re: using redirection (>) as part of an exec using find

From: Alex Hunsley (lard_at_tardis.ed.ac.molar.uk)
Date: 11/28/04


Date: Sun, 28 Nov 2004 19:24:23 GMT

Andrew Tkachenko wrote:
> Alex Hunsley wrote on 28 Ноябрь 2004 13:37:
>
>
>>Bit Twister wrote:
>>
>>>On Sun, 28 Nov 2004 03:37:08 GMT, Alex Hunsley wrote:
>>>
>>>
>>>>I'm using antiword to convert a load of word documents into text files.
>>>>So I thought I'd use the find command to locate doc files in current and
>>>>all subdirs and convert them. A first bash at it (no pun intended :])
>>>>looks like this:
>>>>
>>>> find . -name '*.doc' -exec antiword.exe {} \;
>>>
>>>
>>>Might try xargs
>>>
>>>find . -type f -name "*.doc" -print | xargs antiword.exe
>>
>>thanks for that! haven't used xargs much before but definitely looks
>
> useful.
>
>>I've tried using xargs in the way you describe but things fall over
>>because some of the word documents have a space character in them. xargs
>>then thinks that 1 filename is actually two (it splits them at the
>>space, not surprisingly). So it would appear there's two routes of attack:
>>
>>1) somehow tell xargs that each whole line of input it gets is a whole
>>parameter and so to escape any spaces it finds
>>2) get the find call to output the file name already escaped
>>
>>any ideas?
>>thanks for your help!
>>alex
>
>
> find . -type f -name "*.doc" -print0 | xargs -r0 antiword.exe
>
> see man for find and xargs.
>

thanks muchly! This does just the trick.
alex



Relevant Pages

  • Re: how to deal with file name containing spaces?
    ... Robert Heller wrote: ... If the space is part of your wildcard string, you can escape just the ... But if I want to pass them to next command by using xargs, ...
    (comp.os.linux.misc)
  • Re: using redirection (>) as part of an exec using find
    ... >>I'm using antiword to convert a load of word documents into text files. ... >>So I thought I'd use the find command to locate doc files in current and ... haven't used xargs much before but definitely looks useful. ... parameter and so to escape any spaces it finds ...
    (comp.unix.shell)
  • Re: using redirection (>) as part of an exec using find
    ... Alex Hunsley wrote on 28 Ноябрь 2004 13:37: ... haven't used xargs much before but definitely looks ... > 1) somehow tell xargs that each whole line of input it gets is a whole ... > parameter and so to escape any spaces it finds ...
    (comp.unix.shell)