 <pre><code>sed 's/$/ /;/[[:space:]]\(0\.\)\{0,1\}0[[:space:]]/!b o s/\([^[:space:]]*\).*/\1 0.0 0/ :o s/ $//' YourFile </code></pre> <p>with formating column</p> <pre><code>sed 's/$/ /;/[[:space:]]\(0\.\)\{0,1\}0[[:space:]]/!b o h;s/[[:space:]].*//;x;s/[^[:space:]]*//;s/[1-9]/0/g;H;x;s/\n// :o s/ $//' YourFile </code></pre>