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
  • 9,662
  • 4
  • 42
  • 64

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
  • 64,710
  • 7
  • 38
  • 55
0

You can use this sed:

sed -i '' '$a\
haha_value=26
' example.txt
anubhava
  • 713,503
  • 59
  • 514
  • 593