Re: awk or sed?
-----BEGIN PGP SIGNED MESSAGE-----
A. M. Varon wrote:
> I have two files say, file1 and file2
>
> file1 contains: file2 contains:
> alpha alpha
> bravo
> charlie
>
> What I want to do is compare the two files, and delete the contents of
> file1 according to file2. So, from the above, I'll have to delete the word
> alpha from file1. Can it be possible using sed? or awk?
If you do not want to worry about regexps, you may try this gawk script:
#!/usr/bin/gawk -f
{
if (ARGIND == 1)
a[$0] = 1
else if (! ($0 in a))
print $0
}
and then do: exclude.gawk file2 file1 > new.file1
(It has to be gawk because mawk has not ARGIND, I'm afraid, but maybe
there are some way to rewrite this for general awk).
-----BEGIN PGP SIGNATURE-----
Version: 2.6.3ia
Charset: latin1
iQCVAgUBNSpKISqK7IlOjMLFAQFY3wP9EmtfMHhMlbJpJ7SCpt8gEjxtzb0NREnj
tnKOgySjPQOFI6yw1QUo1KmyVRduHWlxN41TXQoU17pxlNfGtAjUeDzuGxvFmXTl
p8RRarlxEGBGjd6XN3a7m4sHtnYOgksQ0FQpX91H4FBfsED3ORhRf/MYvBUTR14T
ZmfncsI2bWc=
=WiWd
-----END PGP SIGNATURE-----
--
To UNSUBSCRIBE, email to debian-user-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Reply to: