match index notation of file1 to the index of file2 and pull out matching rows

后端 未结 5 548
夕颜
夕颜 2021-01-29 04:47

file1 contains multiple alphabetic sequences:

AETYUIOOILAKSJ
EAYEURIOPOSIDK
RYXURIAJSKDMAO
URITORIEJAHSJD
YWQIAKSJDHFKCM
HAJSUDIDSJSIAJ
AJDHDPFDIXSIBJ
JAQIAUXCNC         


        
5条回答
  •  迷失自我
    2021-01-29 05:07

    With GNU awk and grep:

    awk -v FPAT='[0-9]+|[A-Z]+' '{ print "^.{" $1-1 "}" $2 }' file1 | grep -Ef - file2
    

    Output:

    AETYUIOOILAKSJ
    RYXURIAJSKDMAO
    URITORIEJAHSJD
    JAQIAUXCNCVUFO
    

提交回复
热议问题