I am trying to replace a string of numbers in the first column using awk, gsub and backreference.
For instance, my input file is
1-00001 1 1-00001
1-00001-01 1 1-00001
1-00001-02 1 1-00001
and my desired output is
1-00001-00 1 1-00001
1-00001-01 1 1-00001
1-00001-02 1 1-00001
I tried the following unix command
awk '{gsub("^1-\([0-9]\)\([0-9]\)\([0-9]\)\([0-9]\)\([0-9]\)$","^1-\1\2\3\4\5-00$",$1); print}' input
and the output was
^1-^A^B^C^D^E-00$ 1 1-00001
1-00001-01 1 1-00001
1-00001-02 1 1-00001
Can anybody tell me what is wrong in my command? Thank you in advance!