Discova
Back to cards
Operating systems1 min readWikipedia, updated 28 November 2026

Expand (Unix)

expand is a shell command that converts tab characters to space characters while maintaining vertical alignment. Originally, developed for Unix and standardized by POSIX, it is available on many operating systems today. The command is available as a separate package for Windows via UnxUtils.

In the following commands, the echo command prints a string of text that includes a tab character, then the output is directed into expand. The resulting output is displayed in hexadecimal and as characters by xxd (dump). At the second prompt, the same echo output is sent directly to xxd. As shown, expand converts the tab (specified as '\t') into spaces.

Adapted from the Wikipedia article, CC BY-SA 4.0. Continue on Wikipedia

Go deeper

Ideas this article links to.