I have a multiline Bash variable:
$WORDS containing one word on each line.
I have another multiline Bash variable:
$LIST also containing one word on each line.
I want to purge
$LIST from any word present into
I currently do that with a
while read and
grep but this is not sexy.
WORDS=$(echo -e 'cat\ntree\nearth\nred') LIST=$(echo -e 'abcd\n1234\nred\nwater\npage\ncat') while read -r LINE; do LIST=$(echo "$LIST" | grep -v "$LINE") done <<< "$WORDS" echo "$LIST"
I think I can do it with
awk but did not managed to make it work.
Can someone explain me how to do it with awk?