1

My input is like this:

pak_c35079_g1_i1|m.14890    Pfam  
pak_c20797_g1_i1|m.3458     ProDom  
pak_c20797_g1_i1|m.3458     Pfam  
pak_c28265_g1_i3|m.9595     TIGRFAM  
pak_c28265_g1_i3|m.9595     Pfam  
.  
.  
.  

I want an output like this:

pak_c35079_g1_i1|m.14890    Pfam
pak_c28265_g1_i3|m.9595     TIGRFAM
pak_c28265_g1_i3|m.9595     Pfam   

Meaning that if a value is repeated in next line (in column A), than delete both lines.

  • 1
    please clarify why the last two lines are included in your example output. – mikeserv Dec 20 '15 at 20:06
1

You can do it with awk:

awk 'BEGIN {last=""; last_line=""} { if (last == $1) {} else {print last_line} last=$1; last_line = $0}' < file_to_proceed

I'm not an awk expert, you will have problems with last line...

  • my expected output would be like this: pak_c35079_g1_i1|m.14890 Pfam could you help again, applogizes for posting an incorrect output...,,!!!! – Waqasuddin Khan Dec 22 '15 at 14:07
0
sed '$!N;/^\([^ ]* \).*\n\1/d;P;D' <in >out

It won't handle three consecutive identical first fields - but that doesn't seem to be what you ask, anyway.

My output is a little different than your example output given your example input:


pak_c35079_g1_i1|m.14890    Pfam  

The sed command above will not print the two lines:

pak_c28265_g1_i3|m.9595     TIGRFAM
pak_c28265_g1_i3|m.9595     Pfam   

...because doing so seems to conflict with the thing you ask for, and so I can only wonder at it being included in your example output at all.

  • I am extremely sorry about that...,,!!!! My expected would be like this: pak_c35079_g1_i1|m.14890 Pfam – Waqasuddin Khan Dec 22 '15 at 14:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.