I need to add text after the last line, but I'm getting this error.
How can I avoid this error keeping the same actions?
sed -i -e '$a\ containers:' -e '$a\ - name: container' -e '$a\ image: httpd' -e '$a\ ports:' -e '$a\ - containerPort: 80' /path/to/file"
^-- SC2154: a is referenced but not assigned.
You have a trailing double quote:
This, along with ShellCheck's warning, indicates that the whole sed command is actually part of a double quoted string. You should read more of the context around where this command was found.
For example, it could actually be part of a larger construct like this:
This would be a real bug that makes the command fail, so it should not be ignored. In this case you would escape the
$
s.