EXPAND(1P)

โœจ EXPAND(1P) โœจ

okay bestie, welcome to the POSIX Programmer's Manual ๐Ÿ’– this is expand(1P) and she is literally the girl who takes your chaotic tabby mess and makes it all neat and spaced out. no cap.

๐Ÿซถ PROLOG, but make it a disclaimer: this manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (so like, go consult the corresponding Linux manual page for the details of Linux behavior, iykyk), or the interface may not even be implemented on Linux at all. tragic but true.

๐ŸŒธ NAME ๐ŸŒธ

expand โ€” convert tabs to spaces. that's it. that's the whole job. iconic behavior honestly ๐Ÿ’…


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

expand [-t tablist] [file...]

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

so here's the tea โ˜• the expand utility shall write files, or the standard input, to the standard output โ€” except every <tab> character gets replaced with one or more <space> characters, however many are needed to pad all the way to the next tab stop. slay.

and listen, the <backspace> characters? those get copied straight to the output, no notes ๐Ÿ’œ and they cause the column position count for tab stop calculations to be decremented. but โ€” and this is important โ€” the column position count shall not be decremented below zero. she does not go negative. periodt.


๐Ÿ’… OPTIONS ๐Ÿ’…

the expand utility shall conform to the Base Definitions volume of POSIX.1โ€2017, Section 12.2, Utility Syntax Guidelines. yes ma'am, we follow the rules here.

the following option shall be supported:

  • -t tablist โ€” specify the tab stops, bestie. the application shall ensure that the argument tablist consists of either a single positive decimal integer, or a list of tabstops. if a single number is given, tabs shall be set that number of column positions apart instead of the default 8.

and if a list of tabstops is given, the application shall ensure that it consists of a list of two or more positive decimal integers, separated by <blank> or <comma> characters, in ascending order. the <tab> characters shall be set at those specific column positions. each tab stop N shall be an integer value greater than zero, and the list is in strictly ascending order. what does that mean? it's taken to mean that, 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. math queen ๐Ÿงฎโœจ

and in the event of expand having to process a <tab> at a position beyond the last of those specified in a multiple tab-stop list โ€” the <tab> shall be replaced by a single <space> in the output. one space. that's it. don't overthink it ๐Ÿ™ˆ


๐Ÿ“ OPERANDS ๐Ÿ“

the following operand shall be supported:

  • file โ€” the pathname of a text file to be used as input.

๐ŸŒˆ STDIN ๐ŸŒˆ

see the INPUT FILES section, babe. go look. it's right there ๐Ÿ‘‡


๐Ÿ’œ INPUT FILES ๐Ÿ’œ

input files shall be text files. text. files. that's the vibe check.


โญ ENVIRONMENT VARIABLES โญ

the following environment variables shall affect the execution of expand:

  • 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. she's the main character, she overrides everyone ๐Ÿ‘‘
  • 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 of LC_MESSAGES.

๐ŸŒธ ASYNCHRONOUS EVENTS ๐ŸŒธ

Default. no drama. we love a low-maintenance queen ๐Ÿ’–


โœจ STDOUT โœจ

the standard output shall be equivalent to the input files with <tab> characters converted into the appropriate number of <space> characters. that's the glow-up, fr fr.


๐ŸŽ€ STDERR ๐ŸŽ€

the standard error shall be used only for diagnostic messages. not for vibes. not for gossip. diagnostics only.


๐Ÿฆ‹ OUTPUT FILES ๐Ÿฆ‹

None. nope. nada. nothing to see here ๐Ÿ™ˆ


๐Ÿ’… EXTENDED DESCRIPTION ๐Ÿ’…

None. she said "no extra lore, moving on" ๐Ÿ’€


๐ŸŒˆ EXIT STATUS ๐ŸŒˆ

the following exit values shall be returned:

  1. 0 โ€” successful completion ๐ŸŽ‰
  2. >0 โ€” an error occurred ๐Ÿ˜ญ

โญ CONSEQUENCES OF ERRORS โญ

the expand utility shall terminate with an error message and non-zero exit status upon encountering difficulties accessing one of the file operands. so like, if she can't get to your file? she's out. doors closed. bye ๐Ÿ’…

the following sections are informative.


๐Ÿ’œ APPLICATION USAGE ๐Ÿ’œ

None. nothing to add, bestie. she's self-explanatory.


๐Ÿ“ EXAMPLES ๐Ÿ“

None. no examples provided in the source, so I'm not about to invent any โ€” we don't do that here, that's not the assignment ๐Ÿซถ


๐Ÿงš RATIONALE ๐Ÿงš

the expand utility is useful for preprocessing text files (before sorting, looking at specific columns, and so on) that contain <tab> characters. like, imagine trying to sort a file full of tabs. nightmare. not on her watch.

see the Base Definitions volume of POSIX.1โ€2017, Section 3.103, Column Position.

the tablist option-argument consists of integers in ascending order. Utility Syntax Guideline 8 mandates that expand shall accept the integers (within the single argument) separated using either <comma> or <blank> characters. either one. she's flexible like that ๐Ÿ’โ€โ™€๏ธ

earlier versions of this standard allowed the following form in the SYNOPSIS:

expand [-tabstop][-tab1,tab2,...,tabn][file ...]

this form is no longer specified by POSIX.1โ€2008 but may be present in some implementations. so if you see it out in the wild, just know it's giving vintage, not giving current standard ๐Ÿ™ˆ


๐Ÿ’– FUTURE DIRECTIONS ๐Ÿ’–

None. the future is unclear but expand is not changing, apparently โœจ


๐Ÿซถ SEE ALSO ๐Ÿซถ

  • tabs
  • unexpand

the Base Definitions volume of POSIX.1โ€2017, Section 3.103, Column Position, Chapter 8, Environment Variables, Section 12.2, Utility Syntax Guidelines.


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 ๐ŸŽ€ huge shoutout to IEEE/The Open Group, 2017 for the original โ€” this rewrite was brought to you by that 2017 energy, and EXPAND(1P) says bye, drink water, and go convert some tabs ๐Ÿ’–โœจ๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from