awk power
2 Attachment(s)
I have 2 files as attached.
f1 contain a lots of lines like this: Quote:
Quote:
I want in f3: Quote:
|
Code:
awk -F~ 'FNR == NR { _[$1]++ } FNR < NR && !_[$1]' f2 f1 > f3 On the contrary, when it encounters a line in f1 whose first field was not listed in f2, the evaluation of _[$1] returns an empty string (that is FALSE) and the negation makes it TRUE: indeed we want these lines be printed out! Hope this helps. |
Just for fun, here's a quick&dirty solution using grep, sed, and bash's process substitution.
Code:
grep -v -f <( sed 's/^/^/' f2 ) f1 |
Although the question was for awk:
Code:
$ join -v 1 -t "~" <(sort f1) <(sort f2) |
All times are GMT -5. The time now is 10:38 AM. |