Last active
August 29, 2015 14:04
-
-
Save imZack/9615cac91d8b46245b44 to your computer and use it in GitHub Desktop.
This script will finds sanji.log's duplicate line.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sets import Set | |
import collections | |
lines = [] | |
with open('/tmp/sanji.log', 'r') as f: | |
lines = f.readlines() | |
boots = list() | |
bufferLines = list() | |
for line in lines: | |
bufferLines.append(' '.join(line.split()[5:])) | |
if line.find('Register Sanji controller OK. Model Name :::::::::: firmware ::::::::::') != -1: | |
boots.append(bufferLines) | |
bufferLines = list() | |
for boot in boots: | |
print set([x for x in boot if boot.count(x) > 1]) # py 2.6 | |
print '\n'.join([x for x, y in collections.Counter(boot).items() if y > 1]) # py >= 2.7 | |
print '=' * 80 |
Author
imZack
commented
Jul 28, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment