Compare File with ignore some line/last line We have two log files in which one is generated from a process. We compare one file(golden file) to another file to check if file correct or not. It should have same value. We generally use diff utility to compare two files. I have got enhancement to add machine information into process generated File. So I want to compare upto previous line and ignore  new changes.
Could Anyone provide me any utility which I can use in python.

Golden File

CMD gen -vdd 0.99 -vss 0 -sinps 0.02 -slew 0.1 -temp -40 -rise -data
CMD gen -vdd 0.99 -vss 0 -sinps 0.06 -slew 0.1 -temp -40 -rise -clock
CMD gen -vdd 0.99 -vss 0 -sinps 0.02 -slew 0.1 -temp -40 -fall -data
CMD gen -vdd 0.99 -vss 0 -sinps 0.02 -slew 0.1 -temp -40 -fall -data
CMD gen -vdd 0.99 -vss 0 -sinps 0.06 -slew 0.1 -temp -40 -rise -clock
CMD gen -vdd 0.99 -vss 0 -sinps 0.02 -slew 0.1 -temp -40 -rise -data
Temp1   Temp2   Temp3   Temp4   Temp5   Temp6
-31.00     -19.00      -3.00       -8.00      43.00      61.00


Process File

CMD gen -vdd 0.99 -vss 0 -sinps 0.02 -slew 0.1 -temp -40 -rise -data
CMD gen -vdd 0.99 -vss 0 -sinps 0.06 -slew 0.1 -temp -40 -rise -clock
CMD gen -vdd 0.99 -vss 0 -sinps 0.02 -slew 0.1 -temp -40 -fall -data
CMD gen -vdd 0.99 -vss 0 -sinps 0.02 -slew 0.1 -temp -40 -fall -data
CMD gen -vdd 0.99 -vss 0 -sinps 0.06 -slew 0.1 -temp -40 -rise -clock
CMD gen -vdd 0.99 -vss 0 -sinps 0.02 -slew 0.1 -temp -40 -rise -data
Temp1   Temp2   Temp3   Temp4   Temp5   Temp6
-31.00     -19.00      -3.00       -8.00      43.00      61.00
 Adding machine name( ignore machine name)


I have write code in following.Can we better way for improve code

data = None
with open("Golden_File",'r+') as f:
    data = f.readlines()
del data[-1]

data_1 = None
with open("cp.log",'r+') as f:
    data_1 = f.readlines()
del data_1[-1]
print cmp(data, data_1)


[Question]: Does cmp function works fine in list also. I have used first time and not sure how internally works.
There is no need for python here, you can use the head command to filter out the last line of a file:

diff &lt;(head -n -1 "Golden_File") &lt;(head -n -1 "cp.log")