Unexpand

Last updated
unexpand
Operating system Unix and Unix-like
Platform Cross-platform
Type Command

unexpand is a shell command that converts space characters to tab characters. [1] Originally, developed for Unix and standardized by POSIX, it is available on many operating systems today.

Contents

In the following commands, the echo command prints a string of text that includes multiple consecutive spaces. The output is directed into unexpand. The resulting output is displayed as octal via od . At the second prompt, the same echo output is sent directly to od. As shown, unexpand converts each sequence of eight spaces to a tab (printed as '\t').

$ echo"                 asdf sdf"|unexpand|od-c 0000000  \t  \t       a   s   d   f       s   d   f  \n0000014$ echo"                 asdf sdf"|od-c 00000000000020       a   s   d   f       s   d   f  \n0000032

See also

References

  1. "unexpand - Compress spaces into tabs". www.ibm.com. Retrieved 2024-05-09.