How do I convert all the spaces within a text file to tabs?

Text files (program source code, program output, nroff output, images, etc) tend to contain a lot of space characters. These can be replaced with more economical tab characters. To do so for the file named 'file', type:

unexpand oldfile > newfile

See 'man expand' for details.