I'm trying to figure out how to delete string inside the file addresses.txt. The string I want to delete on addresses.txt was on removed.txt. I have a file addresses.txt and it includes the ff format:
test@foo.com
true@fee.com
fee@tik.com
ew@kit.com
test@foo.com
true@fee.com
fee@tik.com
ew@kit.com
Now, I have a file removed.txt. removed.txt contains a word
test@foo.com
ew@kit.com
How can I remove it on addresses.txt. If I have one entry on removed.txt, I do it this way
Quote:
address=/root/scripts/addresses.txt
remove=`cat /root/scripts/removed.txt`
cat $address | grep -v $remove
|
However, if there is more than 1 entries on removed.txt, it will now encounter an error using grep.
I believe I can do this using sed. Just don't know the exact parameters.
I do try the ff but it seems do not work:
Quote:
#!/bin/bash
address=/root/scripts/addresses.txt
remove=`cat /root/scripts/removed.txt`
for REMOVE in remove;do
sed -i "/$REMOVE/d" $address
done
|
Any advise?