03-14-07 12:17 AM
Rafael Almeida wrote:[vbcol=seagreen]
> Hello,
>
> Is there some tool like merge but for 2 files? I was trying to
> work with merge, but I can't seem to get what I want. This is what I
> get:
> $ cat hosts
> # $OpenBSD: hosts,v 1.11 2002/09/26 23:35:51 krw Exp $
> #
> # Host Database
> #
> # RFC 1918 specifies that these networks are "internal".
> # 10.0.0.0 10.255.255.255
> # 172.16.0.0 172.31.255.255
> # 192.168.0.0 192.168.255.255
> #
> ::1 localhost.boozar.com localhost
> 127.0.0.1 localhost.boozar.com localhost
> ::1 blimp.boozar.com blimp
> 127.0.0.1 blimp.boozar.com blimp
> $cat hosts2
> # $OpenBSD: hosts,v 1.11 2002/09/26 23:35:51 krw Exp $
> #
> # Host Database
> #
> # RFC 1918 specifies that these networks are "internal".
> # 10.0.0.0 10.255.255.255
> # 172.16.0.0 172.31.255.255
> # 192.168.0.0 192.168.255.255
> #
> ::1 localhost.my.domain localhost
> 127.0.0.1 localhost.my.domain localhost
> ::1 noname.my.domain noname
> 127.0.0.1 noname.my.domain noname
> $ merge empty hosts hosts2
> merge: warning: overlaps or other problems during merge
> $ cat empty
> <<<<<<< empty
> =======
> # $OpenBSD: hosts,v 1.11 2002/09/26 23:35:51 krw Exp $
> #
> # Host Database
> #
> # RFC 1918 specifies that these networks are "internal".
> # 10.0.0.0 10.255.255.255
> # 172.16.0.0 172.31.255.255
> # 192.168.0.0 192.168.255.255
> #
> ::1 localhost.my.domain localhost
> 127.0.0.1 localhost.my.domain localhost
> ::1 noname.my.domain noname
> 127.0.0.1 noname.my.domain noname
>
> and this is what I expect the output to be:
> # $OpenBSD: hosts,v 1.11 2002/09/26 23:35:51 krw Exp $
> #
> # Host Database
> #
> # RFC 1918 specifies that these networks are "internal".
> # 10.0.0.0 10.255.255.255
> # 172.16.0.0 172.31.255.255
> # 192.168.0.0 192.168.255.255
> #
> <<<<<<< hosts
> ::1 localhost.boozar.com localhost
> 127.0.0.1 localhost.boozar.com localhost
> ::1 blimp.boozar.com blimp
> 127.0.0.1 blimp.boozar.com blimp
> =======
> ::1 localhost.my.domain localhost
> 127.0.0.1 localhost.my.domain localhost
> ::1 noname.my.domain noname
> 127.0.0.1 noname.my.domain noname
Sorry don't know about the merge command.
Perhaps you can cope with
awk 's[$0]++==0' hosts hosts2
which concatenates hosts and hosts2 but does not print
duplicate lines.
(It stores/compares all line in/with the s array.)
--
Michael Tosch @ hp : com
[ Post a follow-up to this message ]
|