file compare using difflib.differ

Joined
Jul 19, 2010
Messages
1
Reaction score
0
Manipulate list output from difflib.differ

Hi,
I am comparing 2 txt files that are ls -R of the etc directory in a linux system. I compared the 2 files using difflib.differ and got this list as my result (i put the dots to keep the list short in here):

[' etc:\n',
' ArchiveSEL\n',
' HOSTNAME\n',
' RMCPUser\n',
.
.
.
' qcleaner\n',
'+ extraFile\n',
' rc.d\n',
' resolv.conf\n',
.
.
.
' xinetd.d\n',
' \n',
' etc/cmm:\n',
.
.
.
' wu-ftpd\n']

I want to be able to take the string with the '+' sign out to do something else. how do i manipulate the list?

my python script goes like this:

file1 = "c:/cmmlog/etc1.txt"
file2 = "c:/cmmlog/etc2.txt"
f1 = open(file1)
f2 = open(file2)
d = difflib.Differ()
result = list(d.compare(f1.readlines(), f2.readlines()))
_pprint (result)
f1.close()
f2.close()
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top