awk - Fill empty columns with 0 -
i have file structure:
1 11827796 2 300 t:0.96 c:0.04 t 1 11827816 1 300 g:1 g
for lines in file have 6 columns instead of 7, want insert 0 between 5th , 6th column have output:
1 11827796 2 300 t:0.96 c:0.04 t 1 11827816 1 300 g:1 0 g
any idea on how can achieve awk.
thanks lot in advance.
here 1 solution:
awk 'nf==6 {$5=$5" 0"}1' file |column -t 1 11827796 2 300 t:0.96 c:0.04 t 1 11827816 1 300 g:1 0 g
if there 6
fields, add 0
, fix column width.
Comments
Post a Comment