I’m dealing with space delimited file with 6 fields:
Pop1 ID60776 62 C 10 62
Pop1 ID62442 13 A 2 13
Pop1 ID63614 56 C 0
Pop1 ID67511 61 T 37 61
Pop1 ID68222 51 A 0
Pop1 ID68407 65 C 16 65
However, in lines 3 and 5, there are only 5 fields. In these cases, the 0 in field 5 is followed by a space character (‘0 ‘).
I would like to find all instances of a space character at the end of a line (i.e. \s$ ) and replace it with space NA (i.e. ‘\sNA’) but I am having real trouble doing so. For example, I have tried sed:
sed s/\\s$/\\sNA/g
but it’s not working. Can someone help me out?
Thank you!
Here’s a couple of equivalent solutions in
awk:and