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
  • 1
    please clarify why the last two lines are included in your example output.
    – mikeserv
    Commented Dec 20, 2015 at 20:06

2 Answers 2

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...

1
  • my expected output would be like this: pak_c35079_g1_i1|m.14890 Pfam could you help again, applogizes for posting an incorrect output...,,!!!! Commented Dec 22, 2015 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.

1
  • I am extremely sorry about that...,,!!!! My expected would be like this: pak_c35079_g1_i1|m.14890 Pfam Commented Dec 22, 2015 at 14:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .