Parsing text file

Hi Friends,

I am back for the second round today - :smiley:

My input text file is this way

Home
friends
friendship meter
Tools
Mirrors
Downloads
My Data
About Us
Help
My own results
 	
BLAT Search Results

   ACTIONS      QUERY           SCORE START  END QSIZE IDENTITY CHRO STRAND  START    END      SPAN
---------------------------------------------------------------------------------------------------
browser details unix.comwild      20    77    96   100 100.0%     1   +    1234567   1234568     20
browser details help.comwild      20    77    96   100 100.0%     1   +    1234567   1234569     20
browser details milk.comwild      20    77    96   100 100.0%     1   +    1234568   1234569     20
Home
friends
friendship meter
Tools
Mirrors
Downloads
My Data
About Us
Help
My own results
 	
BLAT Search Results

   ACTIONS      QUERY           SCORE START  END QSIZE IDENTITY CHRO STRAND  START    END      SPAN
---------------------------------------------------------------------------------------------------
browser details bulk.comwild      20    77    96   100 100.0%     1   +    1234567   1234568     20
browser details pulp.comwild      20    77    96   100 100.0%     1   +    1234567   1234569     20
browser details gulp.comwild      20    77    96   100 100.0%     1   +    1234568   1234569     20

My expected output is

unix.comwild 1234567 1234568
help.comwild 1234567 1234569
milk.comwild 1234568 1234569
bulk.comwild 1234567 1234568
pulp.comwild 1234567 1234569
gulp.comwild 1234568 1234569

Basically, I want to delete the preceding basic information and printing the third, 11th and 12th column from the table. Please keep in mind that the input text is separated by uneven space delimiter. My output can have tab delimited.

Thanks

Try this:

awk 'NF>12{print $3,$11,$12 }' OFS='\t' infile
1 Like
awk '/--*$/ {d=1;next} d && !/Home/ {print $3,$11,$12}/Home/{d=0}' OFS='\t' myFile
1 Like

What if I also want to apply another condition saying that the 8th column/Identity should be 100.0%?

Thanks for ur time.

awk '/--*$/ {d=1;next} d && !/Home/ && int($8)==100{print $3,$11,$12}/Home/{d=0}' OFS='\t' myFile

You should be able to make the simple changes yourself with 7K posts already...

1 Like

This will output your 3 columns(space delimited), "t" is your file:

sed '/^browser/!d' t | awk '{print $3 " " $11 " " $12}'

@vgersh99, OP only has 181 posts, think your looking at you own post count, LOL.

awk 'NF>12&&$8+0==100{print $3,$11,$12 }' OFS='\t' infile

true - so *I* should be able to make simple changes to my own code :wink: