Search code examples
perlawknormalize

awk cartesian product


I have large tab-separated two-column text file, like this:

...
"001R_FRG3G"    "81941549; 47060116; 49237298"
"002L_FRG3G"    "49237299; 47060117; 81941548"
"002R_IIV3" "106073503; 123808694; 109287880"
...

As you see second column doesn't contain atomic values. That's why i want to "normalise" this file to have something like:

...
"001R_FRG3G"    "81941549"
"001R_FRG3G"    "47060116"
"001R_FRG3G"    "49237298"
"002L_FRG3G"    "49237299"
"002L_FRG3G"    "47060117"
"002L_FRG3G"    "81941548"
"002R_IIV3" "106073503"
"002R_IIV3" "123808694"
"002R_IIV3" "109287880"
...

Anyone knows how to do it effectively?


Solution

  • Perl:

    perl -lne '
    s/[";]//g;
    ($a, @b) = split;
    print qq("$a" "$_") for @b;
    ' FILE