Can't get sed to work
I am getting my current IP address like this:
myIP=$(ip addr show dev eth0 | grep "inet " | cut -d" " -f6 | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}')
(myIP then = 12.34.567.890)
When I try this, it can't find it to delete it out of the file:
(line in file = '1 12.34.567.890')
sed -i "/$myIP/d" temp.txt # remove my IP for safety
When I do this, it finds it and deletes it:
myIP="12.34.567.890"
sed -i "/$myIP/d" temp.txt # remove my IP for safety
Any suggestions? Thanks.
|