Expand

From Initq

Jump to: navigation, search


expand is a command in the UNIX Operating System. It is used to convert groups of tabs into space characters. You may need this for any program that is particular about tabs and you need to quickly convert tabs to spaces.

For example:

$ echo -e "\t foo" | expand | od -c
0000000                                       f   o   o  \n
0000015
$ echo -e "\t foo" | od -c
0000000  \t       f   o   o  \n
0000006

Here the echo command prints a string of text that includes a tab character, then the output is directed into the expand command. The resulting output is then displayed by the octal dump command od. At the second prompt, the same echo output is sent directly through the od command. As can be seen by comparing the two, the expand program converts the tab (printed as '\t') into spaces.

Personal tools