0

I'm trying to append to the end of a file, using the style from this answer but I get the error:

sed: -e expression #1, char 16: unterminated address regex

the command (I've also tried without the -i and same error):

sed -i -e '\$ahaha_value=26' example.txt

where I'm expecting $ to get the end of the file and a to append.

I've looked at these questions here, here, and here. The issues there seem to be regex based and I don't see the issue with my regex.

Community
  • 1
  • 1
depperm
  • 10,606
  • 4
  • 43
  • 67

2 Answers2

2

With single quotes you don't need to escape $ sign since it's not going to be evaluated by shell.

Either

 sed -e '$a...'

or

sed -e "\$a..."
karakfa
  • 66,216
  • 7
  • 41
  • 56
0

You can use this sed:

sed -i '' '$a\
haha_value=26
' example.txt
anubhava
  • 761,203
  • 64
  • 569
  • 643