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

From: Andrew Tkachenko (and11_at_rol.ru)
Date: 11/28/04


Date: Sun, 28 Nov 2004 17:36:25 +0000

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.

-- 
Andrew


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: Why has "find ... -exec rm -i {} ;" stopped working?
    ... > same behaviour is a different one: Here, find's stdin filehandle would ... > somehow have to be passed through to rm (via xargs, ...
    (Debian-User)
  • Re: using redirection (>) as part of an exec using find
    ... Andrew Tkachenko wrote: ... >>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. ... >>parameter and so to escape any spaces it finds ...
    (comp.unix.shell)