I have this data below for example:
Name Chrom Position
rs1 1 1234
rs2 1 1789
rs3 1 1289
1 1 1269
2 1 1897
rs'chrom''position'
rs11269
Name Chrom Position
rs1 1 1234
rs2 1 1789
rs3 1 1289
rs11269 1 1269
rs11897 1 1897
awk '!/rs/{print $1}' file
You can use this command:
$ awk 'BEGIN{FS=OFS="\t"}NR>1&&!($1~/rs/){$1="rs"$2$3}1' file
Name Chrom Position
rs1 1 1234
rs2 1 1789
rs3 1 1289
rs11269 1 1269
rs11897 1 1897
With BEGIN{FS=OFS="\t"}
we set the input and output field separators to the tab character, with NR>1&&!($1~/rs/)
we filter the lines that are not the first (header) and that do not contain the string "rs" in the first field, and with {$1="rs"$2$3}
we change the value of the first field to the desired value. The final 1
is the true condition, so that all lines are printed.