% echo "ABCDE 123 |@ TEST" | sed 's,|@,|,'
its essentially the same as your other question.
grep -v
is enough. The flag -f
allows you to do exactly what you want:
grep -vf Banned.txt Emails.txt
If you want to do something more complicated out of the list of banned addresses, e.g. impose that they match the whole of the domain, you'll need to generate a regex from your Banned
file:
cat Banned.txt | tr "\n" "|" | sed -e 's,|,$\\|,g' | sed -e 's,\\|$,,'
gives the desired
@gotmail.com$\|@cmail.com$\|@uor.edu$
Then:
cat Banned.txt | tr "\n" "|" | sed -e 's,|,$\\\\|,g' | sed -e 's,\\|$,,' | xargs -i grep -v '{}' Emails.txt
(doubling the number of escapes \
as they're being evaluated when going through xargs
). This will match and remove me@uor.edu
but not e.g. me@uor.education.gov
.
Best Answer
Basically you are emulating tail. X = 20 in this example. The following example will delete all but the last 20 lines:
Explanation: