Modifying \n\r on a directory tree of html files to \n files for UNIX 
Author Message
 Modifying \n\r on a directory tree of html files to \n files for UNIX

I am trying to figure out how to change an entire directory of html
files which have the \r\n line termination to the unix style with just
a \n. I looked at dejanews and I found this simple one line by Mr.
McClellan to change a single file named joe.pl.


You can do that with a perl one-liner too:

perl -pi.bak -e 's/\r//' joe.pl

(joe.pl.bak will hold the original (DOS) contents)

How can I make this so it traverses down a directory tree and modifies
all .html files? I could not find a recursive switch in the Camel
book. It seems that having the -i.bak switch is a good idea, but how
would I get rid of the .bak files once I determine the perl command
routine was a success?

Brian

--------------------
Brian Lavender
Sacramento, CA
http://www.*-*-*.com/

"For best results, squeeze from the bottom and flatten as you go up."
             -- Colgate Toothpaste Tube



Sat, 08 Jul 2000 03:00:00 GMT  
 Modifying \n\r on a directory tree of html files to \n files for UNIX



Quote:
>perl -pi.bak -e 's/\r//' joe.pl

>(joe.pl.bak will hold the original (DOS) contents)

>How can I make this so it traverses down a directory tree and modifies
>all .html files? I could not find a recursive switch in the Camel
>book. It seems that having the -i.bak switch is a good idea, but how
>would I get rid of the .bak files once I determine the perl command
>routine was a success?

[hmmm... see how much I can annoy people by proposing a solution _not_
written in Perl]

From the Bourne Shell (I presume you are using Unix from the nature of
your problem), try:

find . -type f -exec perl -pi.bak -e 's/\r//' {} \;

and

find . -type f -name \*.bak -exec rm {} \;

to remove all the *.bak files.

--
Ed Avis



Mon, 10 Jul 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Modifying \n\r on a directory tree of html files to \n files for UNIX

2. Modifying all files in a directory tree?

3. Needed: Script for file tree delete and file tree move

4. count lines in files in a directory tree

5. Change Last Modified for all files in a directory

6. ftp changed files in a directory tree?

7. Checking files in a directory tree

8. Problem preserving UID/GID info using File::Path in creating directory tree

9. ANNOUNCE: lntree - Link files in directory trees

10. perform operations on files withing directory tree

11. converting file names down a directory tree

12. WinNT: getting File Last Modified data from outside current directory

 

 
Powered by phpBB® Forum Software