0

I have the following file:

transcr_15824 -
YML042W -
transcr_18545 -
YCR105W +
transcr_16934 +
YDR032C +
transcr_15237 +
YDL008W -

I do need something that looks like this:

transcr_15824 -
YML042W -
Match
transcr_18545 -
YCR105W +
Not
transcr_16934 +
YDR032C +
Match
transcr_15237 +
YDL008W -
Not

Edit: Basically I need to compare the second column for each two lines. If second column for the first line matches with the second column for the second line, it's a match. If second column for the first line doesn't match with the second column for the second line, it's not a match.

2

Here's one way:

$ awk '{print} !(NR%2){if($2 == last) print "Match"; else print "Not"} {last = $2}' file
transcr_15824 -
YML042W -
Match
transcr_18545 -
YCR105W +
Not
transcr_16934 +
YDR032C +
Match
transcr_15237 +
YDL008W -
Not
0
perl -pae '($_ .= <>) .= qw/NO MATCH/[0+/\n.*\s\Q$F[1]\E$/] . $/'  input

Operate perl in auto split mode. 2nd field is $F[1] is compared in the next line, <>, and depending on itz presence match or no match is appended to the current line $_.

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.