Hi,

Dear Community,

I have a column like this:

    D309
    E308
    G296
    T297A
    P415T
    P415T
    V457I
    V457
    A214G
    A214
    T418
    I419V
    P259
    P259L
    L191
    A190
    R478
    R478H
.
..
...

or in other words you can say that this column is present in a very big file as column number 19. I want only those lines in which the number matches only with the next line, that is the output should be like this:

    P415T
    P415T
    V457I
    V457
    A214G
    A214
    T418
    I419V
    P259
    P259L
    R478
    R478H

I tried this command:

cut -f19 mycolumnfile.txt | uniq -d

I got this output:

    P415T

As it matches with the whole line. I want only those rows in which the number matches only.

Thanks,

Waqas.
Hi,

I would do it in python, with your list of id in the file "list" (beware, not carefully tested) 

    import re
    
    with open("./list", 'r') as f1:
        first = True
        last_int = 0
        last_line = ""
        for line in f1:
            if(last_int == int(re.findall("\d+", line)[0])):
                if first:
                    print last_line
                    print line
                    first = False
                else:
                    print line
            else:
                first = True
            last_int = int(re.findall("\d+", line)[0])
            last_line = line