I have a header and what to add the prefix "f4_" to each column.
I tried this:
echo -e p.value"\t"beta | sed "s/\</f4_/g"
and got this:
f4_p.f4_value f4_beta
I want this:
f4_p.value f4_beta
I think the special character . in the header is messing this up but I am not sure how to fix
You can try this awk:
printf 'p.value\tbeta\n' |
awk 'BEGIN{FS=OFS="\t"}
{for (i=1; i<=NF; ++i) ($i != "") && $i = "f4_" $i} 1'
f4_p.value f4_beta
For a no loop solution suggest you to use this gnu-awk solutiom:
printf 'p.value\tbeta\n' |
awk -v RS='[\t\n]+' 'NF{$0 = "f4_" $0} {ORS=RT} 1'
f4_p.value f4_beta
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With