dave

Escaping Apostrophes in Sed

I’ve had a need to escape a literal apostrophe in an email and couldn’t figure out how to do it. Until I found this post on the Sed Yahoo Group:

sed has supported apostrophe substitution for many years. Use the xHH
notation to indicate any hex character. Since the apostrophe is 0×27,
you can do this:

sed ‘s/x27/\&/g’ infile >outfile

HTW

Original Posting

Leave a Reply