sed is broken under freebsd?

Chris H chris# at 1command.com
Fri Jan 14 08:01:55 UTC 2011


On Thu, January 13, 2011 11:45 am, Alban Hertroys wrote:
> On 13 Jan 2011, at 6:10, Chris H wrote:
>
>> FWIW On a hunch, I just performed an experimentwith sed(1)
>> against gsed on 50,000 html documents. My mission; to replace all instances of:
>>  <HTML>
>> <HEAD>
>>
>>
>> with:
>>
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
>> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
>> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" dir="ltr">
>>
>
>
> I do hope you didn't orphan a </head>-tag there?

LOL Good catch!
Nope. I guess my copy/paste skills aren't so good, when it comes
to my mail reader. :)

This is the actual script I used:

fixem.sh
#!/bin/sh -
# WARNING - there is NO turning back!
for name in $(find . -type f -name '*.html')
do
    sed -f fixem.sed <$name >temp.txt
    mv temp.txt $name
done
rm -f temp.txt

fixem.sed
/\<HTML\>/d
s/\<HEAD\>/\<\?xml\ version\=\"1\.0\"\ encoding\=\"UTF\-8\"\?\>\
\<\!DOCTYPE\ html\ PUBLIC\ \"\-\/\/W3C\/\/DTD\ XHTML\ 1\.0\ Strict\/\/EN\"\
\ \"http\:\/\/www\.w3\.org\/TR\/xhtml1\/DTD\/xhtml1\-strict\.dtd\"\>\
\<html\ xmlns\=\"http\:\/\/www\.w3\.org\/1999\/xhtml\"\ xml\:lang\=\"en\"\
dir\=\"ltr\"\>\
\<head\>/s


--Chris





>
>
> Alban Hertroys
>
>
> --
> If you can't see the forest for the trees,
> cut the trees and you'll see there is no forest.
>
>
> !DSPAM:74,4d2f565011879296619823!
>
>
>
> _______________________________________________
> freebsd-stable at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-stable
> To unsubscribe, send any mail to "freebsd-stable-unsubscribe at freebsd.org"
>
>


-- 




More information about the freebsd-stable mailing list