I am trying to add a tab after the last digit in $3
in the input. The grep
below is all I can think off. Thank you
sed -n 's/[:digit]:/&/p' input
input
chr1 955542 955763AGRN-6|gc=75
chr1 957570 957852AGRN-7|gc=61.2
chr1 976034 976270AGRN-9|gc=74.5
desired output
chr1 955542 955763 AGRN-6|gc=75
chr1 957570 957852 AGRN-7|gc=61.2
chr1 976034 976270 AGRN-9|gc=74.5
Aia
2
perl -pe 's/^.*\s+.*\s+\d+/$&\t/' cmccabe.input
perl -pe 's/AGRN-/\t$&/' cmcabe.input
1 Like
rdrtx1
3
try also:
awk '{i=match($3, /[^0-9]/); $3=substr($3, 1, i-1) "\t" substr($3, i); print}' input
1 Like
Hello cmccabe,
Considering that your Input_file's $3
always have AGRN
or any alphabet that segregates the digits in 3rd field then following may help you in same.
awk '{sub(/[[:alpha:]]+/,"\t&",$3);print}' OFS="\t" Input_file
Output will be as follows.
chr1 955542 955763 AGRN-6|gc=75
chr1 957570 957852 AGRN-7|gc=61.2
chr1 976034 976270 AGRN-9|gc=74.5
Thanks,
R. Singh
1 Like
RudiC
5
Modifying your sed
command:
sed 's/\([[:alnum:]]*[[:space:]]*\)\{2\}[[:digit:]]*/&\t/' file
1 Like
Thank you all very much :).