Gentoo Archives: gentoo-user

From: Teresa and Dale <teendale@×××××××××××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Re: [OT] Question about duplicate lines in file
Date: Mon, 12 Jun 2006 23:03:05
Message-Id: 448DF025.4010600@vista-express.com
In Reply to: Re: [gentoo-user] Re: [OT] Question about duplicate lines in file by Neil Bothwick
1 Neil Bothwick wrote:
2
3 >On Mon, 12 Jun 2006 20:39:20 +0200, Alan McKinnon wrote:
4 >
5 >
6 >
7 >>If /etc/hosts has these lines:
8 >>127.0.0.1 localhost
9 >>127.0.0.1 localhost
10 >>uniq will see these as different even though they are actually the
11 >>same entry. So he needs something like tr to squash spaces. This will
12 >>do it (as root):
13 >>
14 >>cat /etc/hosts | tr -s ' ' | sort | uniq -i > /etc/hosts.new
15 >>
16 >>
17 >
18 >sort -u -k1,1 /etc/hosts >/etc/hosts.new
19 >
20 >avoids the need to use cat, uniq or tr. -k1,1 sorts on the first field
21 >(space delimited) and -u remove lines where the sort field is the same.
22 >
23 >
24 >
25 >
26
27 Well that removed a few, all of them to be exact. The file was blank.
28 O_O LOL I'm learning though.
29
30 Dale
31 :-)
32 --
33 gentoo-user@g.o mailing list

Replies

Subject Author
Re: [gentoo-user] Re: [OT] Question about duplicate lines in file Neil Bothwick <neil@××××××××××.uk>