in reply to Recursive File Substitution

$ perl -MFile::Find -e'find(sub{next if -d or /^\.\.?/ or /\.(jpe?g|gi +f|png)$/;print "$File::Find::name "},".")' | xargs perl -pi.bak -e 's +/\r//g'
8^)

Replies are listed 'Best First'.
Re: Re: Recursive File Substitution
by Anonymous Monk on Jul 12, 2002 at 11:14 UTC
    find . -type f -print | xargs perl -pi -e 's/\r//g'
      ..slightly different:
      perl -pi.orig -e 's/\cM//g' `find . -type f`
        That's not going to work if you have filenames with spaces in them. Piping it through xargs -0 (and don't forget the -print0 option for find) works better, although you will still have problems with filenames ending or beginning with a pipe symbol, beginning with a greater than or less than symbol, files named -, or files beginning or ending with whitespace. All due to the magic open (All hail magic open!).

        We can however do the substitution without a body:

        find . -type f -print0 | xargs -0 perl -0777lpwi.bak -015e' '

        Abigail

        You mean that this little bitty one liner does everything that the huge program above does?