I have a file in which "-"(by itself and nothing else) occurs in different fields in each record(sometimes in the 3 field, sometime in the 20th field, some time in the 100th field....etc). Also there are field of the format "abc-def". How do I replace fields that have just "-" with number zero. sed replaces all the "-", like "abc-def" would become "abc0def", I don't want that to happen.
What are the fields delimited by?
its a tab delimited file. I am trying to use gawk to replace the "-"
I've never used gawk, but sed can do the trick.
cat blah
abc-def - ghi-jkl - mno-pqr
sed 's/\t-\t/\t0\t/g' blah.dat > new_blah.dat
cat new_blah.dat
abc-def 0 ghi-jkl 0 mno-pqr
Thanks!!