On Tue, Feb 28, 2012 at 05:10:40PM +0100, John Kearney wrote:
> so for the test case the goal is to take a string like
> kljlksdjflsd'jkjkljl
> wrap it with single quotes and globally replace all single quotes in the
> string with '\''

Is this an SQL thing?  Maybe you'd be better off using a language that
has an actual interface for database queries, including prepared
statements with variables and so on.

But if you insist:

imadev:~$ q=\'
imadev:~$ input="kljlksdjflsd'jkjkljl"
imadev:~$ echo "'${input//$q/$q\\$q$q}'"
'kljlksdjflsd'\''jkjkljl'

Reply via email to