expand (Unix)

expand is a program that converts tab characters into groups of space characters, while maintaining correct alignment. It is available in Unix operating systems and many Unix-like operating systems.

expand
Operating systemUnix and Unix-like
TypeCommand

Example

For example:

$ echo -e "foo\tbar" | expand | xxd -g 1 -u
0000000: 66 6F 6F 20 20 20 20 20 62 61 72 0A              foo     bar.
$ echo -e "foo\tbar" | xxd -g 1 -u
0000000: 66 6F 6F 09 62 61 72 0A                          foo.bar.
$

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 in hexadecimal and as characters by the xxd dump command. At the second prompt, the same echo output is sent directly to the xxd command. As can be seen by comparing the two, the expand program converts the tab (specified as '\t' to the echo program) into spaces.

gollark: We're not rational beings taking a lot of computing shortcuts, we *are* computing shortcuts.
gollark: Maybe they save computing power over actually being sensible, but they cause problems.
gollark: Sometimes they're just weird bizarre broken reasoning quirks.
gollark: Sometimes they are really bad at "calculating an approximation of truth".
gollark: I mean, they're possibly things which would have worked better at propagating humans' genes or whatever in the "ancestral environment" where we evolved than... the alternative.

See also

  • expand: convert tabs to spaces  Commands & Utilities Reference, The Single UNIX Specification, Issue 7 from The Open Group
This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.