Reputation: 3022
I am trying to add a +
in a specific field $4
in a tab delineated file. Thank you :).
input
chr12 9221325 9221448 chr12:9221325-9221448 A2M
chr12 9222330 9222419 chr12:9222330-9222419 A2M
chr12 9223073 9223184 chr12:9223073-9223184 A2M
desired output
chr12 9221325 9221448 + A2M
chr12 9222330 9222419 + A2M
chr12 9223073 9223184 + A2M
sed so far (no specific to field)
sed 's/$/\t+/' < input > output
Upvotes: 1
Views: 426
Reputation: 10149
Use awk:
awk 'BEGIN{FS=OFS="\t"} {$4="+"; print}' yourfile
It sets the fourth field to +
and then print the fields.
Upvotes: 5