Re: Recursive invocation of a unix command on multiple files under a directory

From: Stein Arne Storslett (sastorsl_at_THOU.SHALT.NOT.SPAM.online.no)
Date: 10/27/04


Date: Wed, 27 Oct 2004 10:04:06 GMT


<nimmi_srivastav@yahoo.com> wrote in <1098866807.487903.157250@z14g2000cwz.googlegroups.com>:
> Does anyone have a suggestion regarding the best way to recursively
> invoke the same command (for example dos2unix or chmod) on all the
> files under a directory?
>
> I started out by using find [ something like find . -type f -exec
> COMMAND {} \; ]. This approach works fine with commands that operate
> on the same file (e.g. chmod), but I am having trouble with commands
> like dos2unix that do not operate on the same file, but send their
> output to the stdout instead (i.e the filters).

FUT set to comp.unix.shell

for i in $(find . -type f)
do
  ux2dos $i > $i.new
done

-- 
Stein Arne


Relevant Pages

  • Re: phpcounter fails after 2 years.
    ... competency of anyone who tells you you need to chmod your files to 777. ... The only other suggestion I might have is to leave a comment on his web ... I don't see any forums, but there is a contact link. ... No response yet. ...
    (alt.php)
  • Re: USB Serial Converters to RS232
    ... Grahame wrote: ... >3> The chmod etc make no differencs, but thanks of the suggestion. ...
    (comp.os.linux.networking)
  • Re: file associations
    ... with the following format ... >chmod +777 register ... Any suggestion? ...
    (alt.os.linux)