mIRC Home    About    Download    Register    News    Help

Print Thread
#107695 12/01/05 01:44 PM
Joined: Jan 2005
Posts: 2
K
Klefths Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
K
Joined: Jan 2005
Posts: 2
Lets say i have 2 big files.(more than 1000 lines)

I want a script theat will give me as an output the 2 files in one file but if a line is in both files it will post it only once.For example

File1

Love
Hate
Work
Code

File2

Mail
Work
Icon
Post

Output

Love
hate
work
code
mail
icon
post

Is there any fast way to do this?

#107696 12/01/05 03:07 PM
Joined: Oct 2004
Posts: 4
K
kof Offline
Self-satisified door
Offline
Self-satisified door
K
Joined: Oct 2004
Posts: 4
/filter file1.txt output.txt *
/filter file2.txt output.txt *

check /help /filter

wink

#107697 12/01/05 03:30 PM
Joined: Jan 2005
Posts: 2
K
Klefths Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
K
Joined: Jan 2005
Posts: 2
I have already checked the help file about filter but i cant ake it work.The one you wrote will just copy the 2 files in one but it wont do exactly what i want.I dont want same lines to be posted twice confused

#107698 12/01/05 03:35 PM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
Code:
filter -fk [color:blue]file1.txt[/color] make_output
filter -fk [color:blue]file2.txt[/color] make_output
alias make_output {
  if (!$read(output.txt,nw,$1-)) { write [color:blue]output.txt[/color] $1- }
}


Change the parts in blue.


New username: hixxy
#107699 12/01/05 09:12 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
This snippet takes advantage of the -n switch that comes with aline, to prevent a line from being added to a window if it's already in there. This makes the need to check obsolete. I'm also using a hidden window, so that is a lot more efficient than writing to a file, especially in the case of 1000+ lines.

Files can contain spaces, and don't necessarily have to be in the mirc folder.

Usage: $nodupes(file1, file2, output file)

Code:
alias nodupes {
  if $0 == 1 { aline -n @@ $$1 }
  elseif $isid && $3 != $null { 
    window -h @@
    filter -fk " $+ $1" nodupes
    filter -fk " $+ $2" nodupes
    savebuf @@ " $+ $3"
    close -@ @@
    return Done 
  }
}


Example: //echo -a $nodupes(file1.txt, file2.txt, c:\program files\my files\output.txt)

Greets


Link Copied to Clipboard