$ echo "${BASH_VERSION}" 5.1.4(1)-release
Linux 5.18.0-17.1-liquorix-amd64 x86_64 GNU/Linux
I have a string export LIBVIRT_DEFAULT_URI='qemu:///system' that I want to find in a user's ~/.profile and delete the entire line. I don't know a good way to do it. Normal use of sed or awk fails with errors and sadly I'm either too dumb or too lazy (or too both) to divine how to fix it.
Where $1 would be the filename and $2 is the string to search for. These things below normally work but seem to crap out in certain situations.
This doesn't work: awk "!/$2/" "$1" > "$1".tmp && mv "$1".tmp "1"
Neither does this: sed -i "/$2/d" $1
Nor this: awk -vLine="$2" "!index($0,$2)" file
Any advice and / or direction is appreciated. I really don't wanna use Perl if I don't have to but at this point I'll take whatever bitter pill that works. Thanks.