perl -pi -e 'while(/\t/g){$d=(4-pos%4)%4+1;$x=q/ /x$d;s/\t/$x/}' filename.txt