SHIFT(1POSIX)
๐ฆ SHIFT(1POSIX) โ the POSIX Programmer's Manual, bestie edition ๐
okay so real talk: this page lives in the POSIX Programmer's Manual, and the Linux version of this interface might be a whole different girl ๐ โ like, the Linux implementation may differ (so go check the corresponding Linux manual page for the tea on Linux behavior), or honestly the interface may not be implemented on Linux at all. so don't come for me if it's not there.
๐ธ PROLOG ๐ธ
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.
โจ NAME โจ
shift โ shift positional parameters ๐ซ
๐ SYNOPSIS ๐
shift [n]
๐ DESCRIPTION ๐
okay bestie, here's the vibe: the positional parameters shall be shifted. so positional parameter 1 shall be assigned the value of parameter (1+n), parameter 2 shall be assigned the value of parameter (2+n), and so on, and so on, it just keeps sliding down the line. โจ
the parameters represented by the numbers "$#" down to "$#-n+1" shall be unset, and the parameter '#' is updated to reflect the new number of positional parameters. so the count gets a lil glow-up too ๐
now, the value n shall be an unsigned decimal integer less than or equal to the value of the special parameter '#'. if n is not given, it shall be assumed to be 1. and if n is 0, the positional and special parameters are not changed โ like, nothing moves, we're just standing here, iconic behavior honestly ๐งโ๏ธ
๐ OPTIONS ๐
None. that's it. no flags, no frills, no notes. ๐ซถ
๐ OPERANDS ๐
See the DESCRIPTION. (the n situation lives up there, go look ๐)
๐ STDIN ๐
Not used. she does not read from stdin, she's above that. ๐
๐ง INPUT FILES ๐ง
None.
๐ ENVIRONMENT VARIABLES ๐
None.
โญ ASYNCHRONOUS EVENTS โญ
Default.
๐ฆ STDOUT ๐ฆ
Not used. no output, she's silent, she's mysterious. ๐
๐ STDERR ๐
The standard error shall be used only for diagnostic messages. that's the only time she speaks up, and it's to tell you something's wrong.
๐ธ OUTPUT FILES ๐ธ
None.
๐ EXTENDED DESCRIPTION ๐
None.
๐ฅ EXIT STATUS ๐ฅ
okay this part matters, listen up:
if the n operand is invalid or is greater than "$#", this may be considered a syntax error and a non-interactive shell may exit ๐ญ โ like, straight up leaving the party. if the shell does not exit in this case, a non-zero exit status shall be returned. otherwise, zero shall be returned. slay. โจ
๐ CONSEQUENCES OF ERRORS ๐
Default.
The following sections are informative.
๐ APPLICATION USAGE ๐
None.
โจ EXAMPLES โจ
look at her go, no cap:
$ set a b c d e
$ shift 2
$ echo $*
c d e
ate. left absolutely no crumbs. ๐
๐ง RATIONALE ๐ง
None.
๐ฎ FUTURE DIRECTIONS ๐ฎ
None.
๐ SEE ALSO ๐
Section 2.14, Special Built-In Utilities
๐ 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, mwah ๐
big love and eternal credit to IEEE / The Open Group, 2017 for this one โ SHIFT(1POSIX) forever in our hearts ๐ซถโจ๐
๐ฆ 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