Reputation: 79
My input looks like this separated by tabs):
Yadda yaddabla blubb_1234 extremlylongtext, with commata
awesomo sappa dwarf_775 extremlylongbutdifferenttext, with commata
The output should be:
Yadda yaddabla S23 blubb_1234 1234 extremlylongtext, with commata
awesomo sappa y5 dwarf_775 775 extremlylongbutdifferenttext, with commata
So I want to repeat only the Numbers after a "_" character seperated with a tab. Any suggestions? : )
Upvotes: 0
Views: 96
Reputation: 31568
awk solution for tab separated file
awk -F"\t" 'BEGIN{OFS="\t";}{$2 = gensub(/_([0-9]+)/,"_\\1\t\\1","g",$2);}1' temp.txt
Upvotes: 0
Reputation: 25052
sed 's/_\([[:digit:]]\{1,\}\)/_\1\t\1/g'
I have shown this with a \t
indicating a tab in the output. If you're not using GNU sed, you may need to replace it with a literal tab.
Upvotes: 1