mIRC Homepage
Posted By: nok Proxy list - 22/12/08 11:09 PM
I am creating a protection for my server ...
I have a listing in a txt, the problem is that there are several repeated, how could delete them?

format of the list
000.000.000.000:0000
Posted By: RusselB Re: Proxy list - 23/12/08 12:08 AM
1) Call up the text file in a text editor (Notepad, Wordpad, WordPerfect, Microsoft Word, etc.) and manually delete the lines that you don't want, then re-save the file when done.

2) Use the /write command with the -d switch to delete the duplicate lines.

See /help /write

Personally, I would recommend the first option, as you will be able to see each change as it is done, then save the file only once, rather than having the file be re-saved with the deleted line each time.
Posted By: nok Re: Proxy list - 23/12/08 05:44 AM
How could display only the number of ip?

$gettok($gettok($1-,-1,91),1,93)

Works in the first instance but not in the second

Example 1
Nick1 (-@host171.190-30-83.host.net => Host-71DFF749.host.net) (asd) [xxx.xx.xx.xxx] connected to the network

Example 2
Nick (-@109-243-231-201.host.com => Host-247F741D.host.com) (xxcap[8.32] • wxw.xxcap.com) [xxx.xxx.xxx.xxx] connected to the network
Posted By: 5618 Re: Proxy list - 23/12/08 06:13 AM
$gettok($gettok($1-,-1,91),1,93)

*notices you either already used -1 or changed your post*

Anyway, that works fine.
Posted By: Typos Re: Proxy list - 23/12/08 10:26 AM
I'm thinking that your list could be pretty long and sorting a list looking for duplicates manually is both very time consuming and can lead to missed duplicates so the first idea that comes to mind is a couple while loops to scan the file for matching lines.

I did briefly test it using:
Quote:
000.000.000.000:0000
111.111.111.111:1111
222.222.222.222:2222
333.333.333.333:3333
111.111.111.111:1111
222.222.222.222:2222
000.000.000.000:0000
111.111.111.111:1111
222.222.222.222:2222
000.000.000.000:0000
111.111.111.111:1111
222.222.222.222:2222
000.000.000.000:0000
111.111.111.111:1111
222.222.222.222:2222
000.000.000.000:0000
111.111.111.111:1111
222.222.222.222:2222
333.333.333.333:3333

And the file was left with only:
Quote:
000.000.000.000:0000
111.111.111.111:1111
222.222.222.222:2222
333.333.333.333:3333

The code I tossed together is:
Code:
alias sortlist {
  var %v1 1
  while (%v1 !> $lines(1.txt)) {
    var %v2 $calc(%v1 + 1)
    while (%v2 !> $lines(1.txt)) {
      if ($read(1.txt,%v1) == $read(1.txt,%v2)) { write -dl $+ %v2 1.txt }
      else { inc %v2 }
    }
    inc %v1
  }
}

It's very simple really, it just goes through the file a line at a time comparing the current line to all other lines below it.

Good luck.
Posted By: kwell Re: Proxy list - 23/12/08 02:24 PM
Another option
Code:
alias sortlist {
  var %v1 = 1 
  while (%v1 <= $lines(1.txt)) {
    write -s $read(1.txt,%v1) proxy.txt $read(1.txt,%v1)
    inc %v1
  }
  write -c 1.txt
}

© mIRC Discussion Forums