Extracting a set of lines from a text file

May 13, 2009 at 02:14:33
Specs: Linux i686
i have a file which look like thus

6 LYS C ?? 999.99 162.37 999.99 -109.28 139.83 -38.02 153.04
7 GLU P Ek -54.40 139.07 176.99 -85.05 -144.26 76.54 999.99
8 LEU E Ck -112.25 149.56 177.92 -54.05 178.76 999.99 999.99
9 VAL E Cl -132.21 157.54 171.95 -71.37 999.99 999.99 999.99
10 LEU E Dk -103.69 137.65 176.45 161.64 64.30 999.99 999.99
11 ALA C Ej -74.49 116.45 173.99 999.99 999.99 999.99 999.99
12 LEU C Df -83.25 -20.95 177.33 -47.38 169.11 999.99 999.99
13 TYR C Bl -145.88 160.42 -176.71 -55.08 -86.79 999.99 999.99
14 ASP P Ek -65.38 145.53 169.48 -82.34 10.88 999.99 999.99


i want to extract the lines based on the 1st column.say c7-10 shld give me all the lines including 7 and 10
and there are white space in the 1st column


See More: Extracting a set of lines from a text file

Report •


#1
May 13, 2009 at 02:36:11
if you have Python, here's an alternative solution

for n,line in enumerate(open("file")):
    if n>=5 and n <=9 :
        print line   


Report •
Related Solutions


Ask Question