$ perl -i.bak -pe 's/ / /g; END {unlink "*.bak"}' file.txt