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. |