I've tried numerous commands, but I am not sure how to use sed in a loop. This is what I have:
VARZ contains CARD_FILE_LIST and it also contains CARD_FILE_LIST2
so
echo "$VARZ"
CARD_FILE_LIST
CARD_FILE_LIST2
I have a file with 60 lines in /tmp/testfile it and I want those lines deleted from the file. Note that VARZ may not always contain CARD_FILE_LIST or CARD_FILE_LIST2. It may contain another line. I want the command to delete whatever values are contained by VARZ preferably with sed or awk.
I have tried:
for i in `cat /tmp/testfile`;do echo $i |sed "s/$VARZ//g"`;done
sed "/$VARZ/d" /tmp/testfile
sed '/'"${VARX}"'/d /tmp/testfile
I have the old version of sed so I can't use sed -i to make changes but obviously I could output it to another file and rename that one if I need to. I just want to get the command/loop working.
Any help is appreciated.