Reputation: 57
I have a requirement to embed single quotes in a string. How can I achieve via shell scripting?
Sample Input: --connect jdbc:sqlserver://XXXX:12;DatabaseName=S
Output: --connect 'jdbc:sqlserver://XXXX:12;DatabaseName=S'
The format of this will always remain same.
Upvotes: 0
Views: 55
Reputation: 1932
You can use the following :
echo "--connect jdbc:sqlserver://XXXX:12;DatabaseName=S" | sed "s| jdbc| 'jdbc|g;s|$|'|g"
Upvotes: 1
Reputation: 4574
you could also escape them :
var=\'hello\'
echo $var
Outputs 'hello'
Upvotes: 0