Reputation: 622
I don't want to escape the single quote below:
a='I'm a $coder.'
Is there a trick to do that?
Upvotes: 1
Views: 72
Reputation:
A two step solution:
$ b='$coder'
$ a="I'm a $b"
$ echo "$a"
I'm a $coder
Upvotes: 0
Reputation: 123570
You can avoid all forms of quoting and escaping using a here document:
IFS= read -rd '' a << "END"
I'm a $coder, hear me roar: ~!@#$%^&*()+"]',/
END
Upvotes: 4
Reputation: 121407
You can use double quotes (without needing to escape):
a="'I'm a $coder.'"
Upvotes: 1