Remove duplicate lines from text files.

 
Thread Tools Search this Thread
Special Forums Windows & DOS: Issues & Discussions Remove duplicate lines from text files.
# 1  
Old 07-28-2014
Remove duplicate lines from text files.

So, I have text files,

one "fail.txt"

Quote:
#000000
#000000
#3B3C3A
#3B3C45
#3D4343
#423D3D
#424143
#433D43
#473B47
#4D3A4A
#AB4603
#B44401
#B54901
#B83C03
#B94806
#BB4401
#E80603
#ED0201
#F00D08
#F40201
#F80706
#FB0102
#3B3C3A
#423D3D
#3B3C45
#433D43
#473B47
#4D3A4A
#3D4343
#424143
#B83C03
#ED0201
#E80603
#F40201
#FB0102
#F80706
#F00D08
#AB4603
#B44401
#BB4401
#B54901
#B94806
#000000
#000000
#000000
#000000
#000000
#000000
#000000
#000000
#000000
#000000
#000000
#000000
And one
"color.txt"
Quote:
#0349A6
#044999
#0574E6
#0576D2
#09387C
#0950AE
#0974BC
#0B3C9D
#0D0B05
#0E9FDE
#11ADEF
#160702
#221F22
#2E1005
#33382E
#34494D
#363B4B
#385131
#38D4F5
#394547
#3A3113
#3A443A
#3A8662
#3B613A
#3C260D
#3C5E52
#3D2A14
#42423E
#452D15
#46D6F5
#472B18
#473219
#473B38
#474546
#483E63
#484639
#4A321A
#4B3823
#4C5535
#4E4E4A
#503118
#506853
#511109
#523A37
#533B23
#557B69
#565C30
#56866E
#573B27
#58442A
#5A0602
#5B442C
#5C4832
#5F8667
#634C34
#64482C
#660803
#664C36
#665139
#676E90
#694F46
#695438
#69637E
#697674
#6B533B
#6B5642
#6C0101
#6C6682
#6C6688
#6E5941
#6F6889
#6F6985
#6F6A4C
#706C93
#70AE94
#712D1D
#72120D
#725639
#726786
#726986
#735C44
#736C89
#73A29F
#750101
#75634A
#765C47
#766447
#76718C
#780807
#791913
#7A0101
#7A654C
#7A6652
#7A694E
#7C6A51
#7C738E
#7E7894
#807793
#830102
#836C54
#837B94
#857D99
#86819C
#8786A5
#887F9B
#888396
#890304
#896E4D
#8A7557
#8A829B
#8B0F12
#8B7C94
#8C788F
#8C7DA1
#8C85A1
#8D2A21
#8D3629
#917A63
#9289A2
#9290AD
#937B59
#938695
#940101
#954731
#988F6B
#990608
#99845C
#9997AA
#9A8667
#9A97B8
#9B0201
#9C94AC
#9DCEB6
#9F96B1
#A199AF
#A39BB3
#A40404
#A49AB5
#A4A494
#A58C68
#A6D8CF
#A798AA
#A8634F
#A88E5B
#A8A8B8
#A95429
#A9936B
#A9A1B6
#AB9774
#ACA4BA
#AD8E6F
#AD94A8
#AEBFD0
#B0A576
#B1170C
#B2300A
#B24E0B
#B2A8BB
#B49C77
#B4ABBE
#B5ADC3
#B6AFB5
#B6B7D2
#B70702
#B71807
#B7ABC9
#B8A47B
#B8AFC2
#B8B5C8
#BAB1C4
#BBA983
#BDB5CB
#BFB087
#C2B9CC
#C44606
#C4B38A
#C5BDD4
#C5C4D5
#C71A0E
#C7BCD9
#C96D57
#C9C1D6
#CAB48E
#CAC2DA
#CC2F0C
#CCBDE7
#CDF4E4
#CFC298
#CFCAEA
#D25D2A
#D2BAD2
#D2C8DB
#D4976F
#D4CCE4
#D6C59C
#D7CCE7
#D9B09E
#DAC9A2
#DAD2E9
#DCD1A3
#E7DAF2
#E8310F
#E9A615
#EA976D
#EBD5A9
#EE6E2F
#F0AC55
#F1C974
#F2934C
#F2EAF7
#F2F378
#F3930A
#F3D190
#F4B771
#F4EE90
#F5833C
#F67839
#F7BD6C
#F7C925
#F7EEE7
#F7EFB2
#F7F1D4
#F87D42
#F89D56
#F8A25A
#F8C375
#F8CE87
#F8D286
#F8EEA7
#F8F1A8
#F8F1C9
#F9D18A
#F9EDC8
#F9F2EA
#FA8243
#FFFFFF

I now want to use a command line (DOS) to remove ANY line that is PRESENT IN BOTH from each text file.

Afterwards there shall be no duplicate lines.
# 2  
Old 07-29-2014
Well in unix-land:-
Code:
grep -vf fail.txt colours.txt   > output.txt
grep -vf colours.txt fail.txt  >> output.txt

I think that you can get a grep for DOS by searching on-line. Maybe Windows Grep: Grep for Windows will suit, but use your favourite search engine with the keywords DOS & GREP.


Robin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to remove duplicate lines?

Hi All, I am storing the result in the variable result_text using the below code. result_text=$(printf "$result_text\t\n$name") The result_text is having the below text. Which is having duplicate lines. file and time for the interval 03:30 - 03:45 file and time for the interval 03:30 - 03:45 ... (4 Replies)
Discussion started by: nalu
4 Replies

2. Shell Programming and Scripting

Remove duplicate lines from a file

Hi, I have a csv file which contains some millions of lines in it. The first line(Header) repeats at every 50000th line. I want to remove all the duplicate headers from the second occurance(should not remove the first line). I don't want to use any pattern from the Header as I have some... (7 Replies)
Discussion started by: sudhakar T
7 Replies

3. UNIX for Dummies Questions & Answers

Remove Duplicate Lines

Hi I need this output. Thanks. Input: TAZ YET FOO FOO VAK TAZ BAR Output: YET VAK BAR (10 Replies)
Discussion started by: tara123
10 Replies

4. Shell Programming and Scripting

How do I remove the duplicate lines in this file?

Hey guys, need some help to fix this script. I am trying to remove all the duplicate lines in this file. I wrote the following script, but does not work. What is the problem? The output file should only contain five lines: Later! (5 Replies)
Discussion started by: Ernst
5 Replies

5. Shell Programming and Scripting

[uniq + awk?] How to remove duplicate blocks of lines in files?

Hello again, I am wanting to remove all duplicate blocks of XML code in a file. This is an example: input: <string-array name="threeItems"> <item>item1</item> <item>item2</item> <item>item3</item> </string-array> <string-array name="twoItems"> <item>item1</item> <item>item2</item>... (19 Replies)
Discussion started by: raidzero
19 Replies

6. Shell Programming and Scripting

Remove duplicate lines

Hi, I have a huge file which is about 50GB. There are many lines. The file format likes 21 rs885550 0 9887804 C C T C C C C C C C 21 rs210498 0 9928860 0 0 C C 0 0 0 0 0 0 21 rs303304 0 9941889 A A A A A A A A A A 22 rs303304 0 9941890 0 A A A A A A A A A The question is that there are a few... (4 Replies)
Discussion started by: zhshqzyc
4 Replies

7. Shell Programming and Scripting

perl/shell need help to remove duplicate lines from files

Dear All, I have multiple files having number of records, consist of more than 10 columns some column values are duplicate and i want to remove these duplicate values from these files. Duplicate values may come in different files.... all files laying in single directory.. Need help to... (3 Replies)
Discussion started by: arvindng
3 Replies

8. Shell Programming and Scripting

Remove duplicate files based on text string?

Hi I have been struggling with a script for removing duplicate messages from a shared mailbox. I would like to search for duplicate messages based on the “Message-ID” string within the messages files. I have managed to find the duplicate “Message-ID” strings and (if I would like) delete... (1 Reply)
Discussion started by: spangberg
1 Replies

9. Shell Programming and Scripting

remove all duplicate lines from all files in one folder

Hi, is it possible to remove all duplicate lines from all txt files in a specific folder? This is too hard for me maybe someone could help. lets say we have an amount of textfiles 1 or 2 or 3 or... maximum 50 each textfile has lines with text. I want all lines of all textfiles... (8 Replies)
Discussion started by: lowmaster
8 Replies

10. Shell Programming and Scripting

how to remove duplicate lines

I have following file content (3 fields each line): 23 888 10.0.0.1 dfh 787 10.0.0.2 dssf dgfas 10.0.0.3 dsgas dg 10.0.0.4 df dasa 10.0.0.5 df dag 10.0.0.5 dfd dfdas 10.0.0.5 dfd dfd 10.0.0.6 daf nfd 10.0.0.6 ... as can be seen, that the third field is ip address and sorted. but... (3 Replies)
Discussion started by: fredao
3 Replies
Login or Register to Ask a Question