In the tab-delimited
input below I am trying to use awk
to -10
from $2
and +10
to $3
. Something like
awk -F'\t' -v OFS='\t' -v s=10 '{split($4,a,":"); print $1,$2-s,$3+s,a[2],$5,$6} | awk {split(a[2],b,"-"); print $1,$2-s,$3+s,b[1]-s,b[2]+s,$5,$6}' input
should do that. I also need to -10
from $4
after the :
but before the -
and +10
from $4
after the :
but after the -
. Thank you :).
input
chr1 948836 948966 chr1:948836-948966 . ISG15
chr1 949353 949929 chr1:949353-949929 . ISG15
chr1 955492 955763 chr1:955492-955763 . AGRN
chr1 955492 955763 chr1:955492-955763 . AGRN
chr1 957570 957852 chr1:957570-957852 . AGRN
desired output (tab-delimited)
chr1 948826 948976 chr1:948826-948976 . ISG15
chr1 949343 949939 chr1:949343-949939 . ISG15
chr1 955482 955773 chr1:955482-955773 . AGRN
chr1 955482 955773 chr1:955482-955773 . AGRN
chr1 957560 957862 chr1:957560-957862 . AGRN
awk
awk -F'\t' -v OFS='\t' -v s=10 '{split($4,a,":"); print $1,$2-s,$3+s,a[2],$5,$6} | awk {split($4,b,"-"); print $1,$2-s,$3+s,b[1]-s,b[2]+s,$5,$6}' input
awk: cmd. line:1: {split($4,a,":"); print $1,$2-s,$3+s,a[2],$5,$6} | awk {split($4,b,"-"); print $1,$2-s,$3+s,b[1]-s,b[2]+s,$5,$6}
awk: cmd. line:1: ^ syntax error