Gentoo Archives: gentoo-user

From: Neil Bothwick <neil@××××××××××.uk>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Re: [OT] Question about duplicate lines in file
Date: Mon, 12 Jun 2006 19:28:35
Message-Id: 20060612201526.3123e8af@hactar.digimed.co.uk
In Reply to: Re: [gentoo-user] Re: [OT] Question about duplicate lines in file by Alan McKinnon
1 On Mon, 12 Jun 2006 20:39:20 +0200, Alan McKinnon wrote:
2
3 > If /etc/hosts has these lines:
4 > 127.0.0.1 localhost
5 > 127.0.0.1 localhost
6 > uniq will see these as different even though they are actually the
7 > same entry. So he needs something like tr to squash spaces. This will
8 > do it (as root):
9 >
10 > cat /etc/hosts | tr -s ' ' | sort | uniq -i > /etc/hosts.new
11
12 sort -u -k1,1 /etc/hosts >/etc/hosts.new
13
14 avoids the need to use cat, uniq or tr. -k1,1 sorts on the first field
15 (space delimited) and -u remove lines where the sort field is the same.
16
17
18 --
19 Neil Bothwick
20
21 Please rotate your phone 90 degrees and try again.

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies

Subject Author
Re: [gentoo-user] Re: [OT] Question about duplicate lines in file Teresa and Dale <teendale@×××××××××××××.com>