expand (Unix)
This articleneeds additional citations forverification.(July 2009) |
Operating system | UnixandUnix-like |
---|---|
Platform | Cross-platform |
Type | Command |
expand
is a program that convertstabcharactersinto groups ofspacecharacters, while maintaining correct alignment. It is available inUnixoperating systemsand manyUnix-likeoperating systems.[1]The command is available as a separate package forMicrosoft Windowsas part of theUnxUtilscollection ofnativeWin32portsof commonGNUUnix-like utilities.[2]
Example
[edit]For example:
$echo-e"foo\tbar"|expand|xxd-g1-u
0000000: 66 6F 6F 20 20 20 20 20 62 61 72 0A foo bar.
$echo-e"foo\tbar"|xxd-g1-u
0000000: 66 6F 6F 09 62 61 72 0A foo.bar.
$
Here theecho
command prints a string of text that includes a tab character, then the output is directed into theexpand
command. The resulting output is then displayed inhexadecimaland as characters by thexxd
dump command. At the second prompt, the sameecho
output is sent directly to thexxd
command. As can be seen by comparing the two, theexpand
program converts the tab (specified as '\t' to theecho
program) into spaces.
See also
[edit]References
[edit]- ^"expand".The Open Group Base Specifications.The Open Group.Retrieved27 April2023.
- ^"Native Win32 ports of some GNU utilities".unxutils.sourceforge.net.
External links
[edit]- The Single UNIX Specification,Version 4 fromThe Open Group :convert tabs to spaces – Shell and Utilities Reference,