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:
-ttablist โ 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 default8.
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 ofLC_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:
0โ successful completion ๐>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 ๐ซถ
tabsunexpand
the Base Definitions volume of POSIX.1โ2017, Section 3.103, Column Position, 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 ๐ 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
- alpine 3.22: man-pages-posix 2017a-r0 ยท custom
- alpine 3.23: man-pages-posix 2017a-r0 ยท custom
- alpine 3.24: man-pages-posix 2017a-r0 ยท custom
- arch rolling: man-pages 6.19-1
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 ยท SUSE-IEEE
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms