I have read all the similar questions on this topic, but didn't find a matching question to what I am experiencing. I apologise if this has been answered already.
Inside a bash script I wrote, there is a very simple sed command, which does not seem to be working. There are no errors, and the command works perfectly when run from the command line.
In the output from set -x I can see the sed command executing perfectly.
GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)
Bash script: (toned down for easier comprehension)
#!/bin/bash -x
# This script has the exact same sed command as used on cli
contact='"tim@email.com"'
sed -i "/$contact/d" /home/tim/Desktop/file.txt
exit
Shell output:
tim@ubuntu:~/Desktop$ cat file.txt
t,b,tim@email.com
tim@ubuntu:~/Desktop$ ./test.sh
+ contact='"tim@email.com"'
+ sed -i '/"tim@email.com"/d' /home/tim/Desktop/file.txt
+ exit
tim@ubuntu:~/Desktop$ cat file.txt
t,b,tim@email.com
tim@ubuntu:~/Desktop$ sed -i "/"tim@email.com"/d" /home/tim/Desktop/file.txt
tim@ubuntu:~/Desktop$ cat file.txt
tim@ubuntu:~/Desktop$
I assume I am missing something very obvious, but I am done staring at it hoping for the answer to jump off the screen and slap me in the face. Please help :-)
Tim