[Techtalk] Escaping single quotes in a file with a bash script

Gretchen Dziengel gdziengel at gmail.com
Wed Jul 11 16:01:05 UTC 2007


I'm trying to write a script that pulls information from a text file and
puts it into a database.  It's a list of e-mail groups and some of the names
have single quotes in them O'Rourke for example.  (I don't think their
actual e-mail address has the ' in it, just their name)

I've usually gotten sed to do all the replacing I need in a script and if I
were to do it with sed it should be
sed -e 's/\'/\\\'/' infile outfile

That SHOULD replace the ' with \' so I can put it into mysql.  I'm getting
an unexpected EOF error.
Google tells me that I can't have single quotes inside single quotes even if
they are escaped.
Is there any way this can be done?  I don't have to do it with sed.  Please
tell me it's something simple that I'm overlooking.

Gretchen


More information about the Techtalk mailing list