This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to replace the "." in a table with "0"

Hi there, I am working with a gff file, however I find that the 8th phase column of CDS are "." instead of integers such as "0" or "1" or "2". Could anyone show me a command line that can replace the "." with "0" in 8th column when the 4th column is CDS?

Thanks!

DDB0232428  Sequencing Center   exon    1890    3287    .   +   .   Parent=DDB0216437
DDB0232428  Sequencing Center   CDS 1890    3287    .   +   .   Parent=DDB0216437
DDB0232428  Sequencing Center   exon    3848    4855    .   +   .   Parent=DDB0216438
DDB0232428  Sequencing Center   CDS 3848    4855    .   +   .   Parent=DDB0216438
next-gen sequence

1 answer

awk 'OFS="\t" {if ($4 == "CDS") $8 = "0"; print $0}' in.gff > out.gff

Log in to answer this question.