1 |
On Tuesday, 13 June 2006 2:49, Teresa and Dale wrote: |
2 |
> Raymond Lewis Rebbeck wrote: |
3 |
> >On Tuesday, 13 June 2006 2:12, Teresa and Dale wrote: |
4 |
> >>Hi folks, |
5 |
> >> |
6 |
> >>I have batched a bunch of servers in my hosts file to block, for ads and |
7 |
> >>all that crap. I got them from several different places, some I have |
8 |
> >>found too, and am sure there are dups in there, same server but pasted |
9 |
> >>from several sources. I am not a programer at all and don't even really |
10 |
> >>know what to search for. I would like to remove the duplicate entries |
11 |
> >>and then put them in alphabetical order if I could. I would gladly then |
12 |
> >>make this available if someone wanted to host it. I don't have a place |
13 |
> >>to host it. |
14 |
> >> |
15 |
> >>Oh, there is 15,000 entries in my hosts file. O_O |
16 |
> >> |
17 |
> >>Could someone tell me how this is done? May even learn something here. |
18 |
> >>If I can do this, I'm sure I will. |
19 |
> >> |
20 |
> >>Thanks. |
21 |
> >> |
22 |
> >>Dale |
23 |
> >> |
24 |
> >>:-) :-) |
25 |
> > |
26 |
> >'uniq' and 'sort' should do what you're after, check out the man pages. |
27 |
> |
28 |
> Thanks, read the man page, it was short so it didn't take long. I tried |
29 |
> this: |
30 |
> |
31 |
> uniq -u /home/dale/Desktop/hosts /home/dale/Desktop/hostsort |
32 |
> |
33 |
> It doesn't look like it did anything but copy the same thing over. |
34 |
> There are only 2 lines missing. Does spaces count? Some put in a lot |
35 |
> of spaces between the localhost and the web address. Maybe that has a |
36 |
> affect?? |
37 |
> |
38 |
> Thanks for the help. I had never seen that command before. I had heard |
39 |
> of sort, never used it though. I do have those on my desktop. I'm |
40 |
> playing with copies instead of my real hosts file. |
41 |
> |
42 |
> Thanks again. |
43 |
> |
44 |
> Dale |
45 |
> |
46 |
> :-) :-) |
47 |
|
48 |
Yes the spaces matter, you could possibly use 'tr' to turn all repeated spaces |
49 |
into a single space. |
50 |
|
51 |
$ tr -s ' ' < filename |
52 |
|
53 |
That should do it, then you can pipe it through uniq and sort and do whatever |
54 |
else you want with it. |
55 |
|
56 |
-- |
57 |
Raymond Lewis Rebbeck |
58 |
-- |
59 |
gentoo-user@g.o mailing list |