UNEXPAND(1POSIX)
π UNEXPAND(1POSIX) π
okay so bestie, welcome to the POSIX Programmer's Manual β¨ this page lives in that collection, and quick heads-up: the Linux version of this whole interface might act a little different (so go peek at the matching Linux man page for the tea), or it might not even be implemented on Linux at all. just so you know π«Ά
πΈ NAME πΈ
unexpand β convert spaces to tabs
like... the glow-up from spaces to tabs. iconic behavior fr fr π
β¨ SYNOPSIS β¨
unexpand [-a|-t tablist] [file...]
π¦ DESCRIPTION π¦
so what this utility does is copy files or standard input over to standard output, and it converts <blank> characters at the beginning of each line into the maximum number of <tab> characters followed by the minimum number of <space> characters needed to fill the exact same column positions that the translated <blank> characters originally filled. no cap, same vibe, fewer characters.
by default, tabstops are set at every eighth column position.
every <backspace> gets copied straight to the output, and it causes the column position count for tab calculations to be decremented β and the count shall never be decremented to a value less than one. so it bottoms out at one, periodt.
π OPTIONS π
unexpand shall conform to the Base Definitions volume of POSIX.1β2017, Section 12.2, Utility Syntax Guidelines.
the following options shall be supported:
-aβ in addition to translating<blank>characters at the beginning of each line, this also translates all sequences of two or more<blank>characters immediately preceding a tab stop into the maximum number of<tab>characters followed by the minimum number of<space>characters needed to fill the same column positions originally filled by the translated<blank>characters. so it's not just leading blanks anymore, it's going further down the line π-t tablistβ specify the tab stops. the application shall ensure that the tablist option-argument is a single argument consisting of a single positive decimal integer, or multiple positive decimal integers, separated by<blank>or<comma>characters, in ascending order.- if a single number is given, tabs shall be set tablist column positions apart instead of the default 8.
- if multiple numbers are given, the tabs shall be set at those specific column positions.
the application shall ensure that each tab-stop position N is an integer value greater than zero, and the list shall be in strictly ascending order. this means: from the start of a line of output, tabbing to position N shall cause the next character output to be in the (N+1)th column position on that line.
when -t is not specified, the default shall be the equivalent of specifying -t 8 β except for the interaction with -a, described below. π
no <space>-to-<tab> conversions shall occur for characters at positions beyond the last of those specified in a multiple tab-stop list.
when-tis specified, the presence or absence of the-aoption shall be ignored; conversion shall not be limited to the processing of leading<blank>characters.-tsaid "i'm the main character now" π
π OPERANDS π
the following operand shall be supported:
- file β a pathname of a text file to be used as input.
π STDIN π
see the INPUT FILES section. (iykyk, it's right down there β¬οΈ)
π INPUT FILES π
the input files shall be text files.
π ENVIRONMENT VARIABLES π
the following environment variables shall affect the execution of unexpand:
LANGβ provide a default value for the internationalization variables that are unset or null. (see the Base Definitions volume of POSIX.1β2017, Section 8.2, Internationalization Variables for the precedence of internationalization variables used to determine the values of locale categories.)LC_ALLβ if set to a non-empty string value, override the values of all the other internationalization variables.LC_CTYPEβ determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multi-byte characters in arguments and input files), the processing of<tab>and<space>characters, and for the determination of the width in column positions each character would occupy on an output device.LC_MESSAGESβ determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.NLSPATHβ determine the location of message catalogs for the processing ofLC_MESSAGES.
β ASYNCHRONOUS EVENTS β
Default. (the standard is giving "no thoughts, head empty" on this one π)
πΈ STDOUT πΈ
the standard output shall be equivalent to the input files with the specified <space>-to-<tab> conversions.
π STDERR π
the standard error shall be used only for diagnostic messages. it's strictly business bestie, no chatting.
π¦ OUTPUT FILES π¦
None.
π§ EXTENDED DESCRIPTION π§
None.
π EXIT STATUS π
the following exit values shall be returned:
0β successful completion.>0β an error occurred.
π₯ CONSEQUENCES OF ERRORS π₯
Default.
the following sections are informative.
π APPLICATION USAGE π
one non-intuitive aspect of unexpand is its restriction to leading <space> characters when neither -a nor -t is specified. so yeah, it's lowkey picky by default π
users who always want to convert all <space> characters in a file can easily alias unexpand to use the -a or -t 8 option. problem solved, slay.
π EXAMPLES π
None.
β¨ RATIONALE β¨
on several occasions, consideration was given to adding a -t option to the unexpand utility to complement the -t in expand (see expand). the historical intent of unexpand was to translate multiple <blank> characters into tab stops, where tab stops were a multiple of eight column positions on most UNIX systems. an early proposal omitted -t because it seemed outside the scope of the User Portability Utilities option; it was not described in any of the base documents for IEEE Std 1003.2β1992. however, hard-coding tab stops every eight columns was not suitable for the international community and broke historical precedents for some vendors in the FORTRAN community, so -t was restored in conjunction with the list of valid extension categories considered by the standard developers. thus, unexpand is now the logical converse of expand. character development arc fr fr π
πΊ FUTURE DIRECTIONS πΊ
None.
π«Ά SEE ALSO π«Ά
expand, tabs
the Base Definitions volume of POSIX.1β2017, Chapter 8, Environment Variables, Section 12.2, Utility Syntax Guidelines
π COPYRIGHT π
portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. in the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. the original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. to report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page bestie!! β¨ this one came to you from IEEE/The Open Group, dated 2017, and it's the UNEXPAND(1POSIX) page β go forth and convert those spaces, you absolute icon ππ
π¦ where this page comes from
- debian bookworm: manpages-posix 2017a-2 Β· Other
- debian trixie: manpages-posix 2017a-2 Β· Other
- ubuntu jammy: manpages-posix 2017a-2 Β· Other
- ubuntu noble: manpages-posix 2017a-2 Β· Other
- ubuntu resolute: manpages-posix 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms