#!/bin/env python
import sys
filein = sys.argv[1]
cutlines = sys.argv[2]
f1 = open(filein).readlines()
list = []
for i in range(cutlines, len(f1)):
list.append(f1[i].rstrip(" "))
fileout = sys.argv[1] + ".new"
f2 = open(fileout, 'w')
f2.writelines(list)
f2.close()
Hmm… I changed it to cut from the top and bottom:
#!/bin/env python
import sys
filein = sys.argv[1]
startlines = int(sys.argv[2])
endlines = int(sys.argv[3])
f1 = open(filein).readlines()
list = []
flag = 0
startcut = len(f1) - endlines
for i in range(startlines, len(f1)):
if (len(f1[i]) == 1) and (flag == 0):
# drop this line
elif (i < startcut):
# keep this line
list.append(f1[i].rstrip(" "))
flag = 1
else:
# drop this line
pass
fileout = sys.argv[1] + ".new"
f2 = open(fileout, 'w')
f2.writelines(list)
f2.close()