[Techtalk] Escaping single quotes in a file with a bash script
Kathryn Hogg
kjh at flyballdogs.com
Wed Jul 11 16:17:05 UTC 2007
Gretchen Dziengel wrote:
> 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.
Use double quotes for the outer level:
sed -e "s/'/\\\'/" infile outfile
--
Kathryn
http://womensfooty.com
More information about the Techtalk
mailing list