[oclug] tr help

Bob Lockie bjlockie at lockie.ca
Fri Nov 14 18:29:33 EST 2003


On 11/14/03 15:38 Glenn Jackman spoke thusly

> On 2003-11-14 15:19, Bob Lockie wrote:
> 
>># tr "\\" "\/"
>>tr: invalid backslash escape at end of string
>>
>>Can I even use tr to output the same file that it inputs?
>>What I need to do is go through all some HTML files and change "\" to "/".
>>Something (MS Word maybe) created some links that use "\" as directory 
>>seperators and Apache uses "/" so I have paths that are a mix of "\" and 
>>"\" when the page loads and therefore some things are broken.
>>
>>I was thinking of doing something like this (but that works):
>>find . -name \*.html -exec tr "\\" "\/" < {} > {} \;
> 
> 
> perl's -i switch enables editing "in place":
>     find . -name \*.html | xargs perl -ipe 's{\\}{/}g'

That was extremely helpful as a place for me to start, thanks.

# find . -name \*.html | xargs perl -ipe 's{\\}{/}g'
Can't open perl script "s{\\}{/}g": No such file or directory



More information about the OCLUG mailing list