I want to append the following line to a text file with sed:
sed -i '$a gem \'forum2discourse\'' Gemfile but this drops me to a
> prompt so I think I must be incorrectly escaping the
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
sed -i '$a gem '"'"'forum2discourse'"'" Gemfile
If you wish to do it your way, then use the bash
$'string' format. Words of the form $'string' are treated specially. The word expands to string, with backslash-escaped characters replaced as specified by the ANSI C standard.
sed -i $'$a gem \'forum2discourse\'' Gemfile