bash sed truncates file instead of replacing text.
I want to update variables in bashrc source with sed but to my surprise sed truncates the file.
For testing i have a little file abc:
export PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export myip=1.2.3.4
and this test script:
#!/bin/bash
myip=1.2.3.4; newip=5.6.7.8
sed -ni 's/$myip/$newip/' abc
running the script leaves abc empty. Why is this so?
I am using Ubuntu 22.04 on an Intel I7.