forked from laconicwolf/Password-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremove_duplicates.py
More file actions
40 lines (33 loc) · 1.18 KB
/
remove_duplicates.py
File metadata and controls
40 lines (33 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python3
__author__ = 'Jake Miller (@LaconicWolf)'
__date__ = '20180921'
__version__ = '0.01'
__description__ = """Reads a file, removes duplicate lines, and writes to a new file."""
import argparse
def main():
print('[*] Reading file: {}'.format(filename))
with open(filename, encoding="utf8", errors='ignore') as fh:
lines = fh.read().splitlines()
print("[*] Processing {} words.".format(len(lines)))
print('[*] Removing duplicate words...')
unique_lines = list(set(lines))
if args.outfile:
print('[*] Writing to file: {}'.format(args.outfile))
with open(args.outfile, 'w', encoding="utf8", errors='ignore') as fh:
for line in unique_lines:
fh.write(line + '\n')
else:
for line in unique_lines:
print(line)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('-f', '--filename')
parser.add_argument('-o', '--outfile')
args = parser.parse_args()
if not args.filename:
parser.print_help()
print("\n[-] Please specify the filename of the wordlist.\n")
exit()
else:
filename = args.filename
main()