Friday, November 20, 2015

Quotes Within Quotes In Linux

I keep forgetting this every time even though I have stumbled across this so many times.
I'm now gonna stick this here so that I can refer it back and hopefully remember this for good.




Basically, the idea is to ....
always just replace each embedded single quote with the sequence: '\'' (that is: quote backslash quote quote) or '"'"' , which closes the string, appends an escaped single quote and reopens the string. 
 https://stackoverflow.com/a/1315213/335181


Putting the above into a perl script works wonder:
#!/usr/bin/perl -pl
s/'/'\\''/g;    ### or s/'/'"'"'/g;
$_ = qq['$_'];



No comments:

Post a Comment

How To Bypass Kerberos(kinit) Authentication

Whenever you try to setuid and impersonate as someone else to run something, it is very likely that you will run into kerberos/kinit issues....