1SHIFT(1P)                  POSIX Programmer's Manual                 SHIFT(1P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10
11

NAME

13       shift — shift positional parameters
14

SYNOPSIS

16       shift [n]
17

DESCRIPTION

19       The positional parameters shall  be  shifted.  Positional  parameter  1
20       shall  be  assigned  the value of parameter (1+n), parameter 2 shall be
21       assigned the value of parameter (2+n), and so on. The parameters repre‐
22       sented  by  the  numbers  "$#" down to "$#−n+1" shall be unset, and the
23       parameter '#' is updated to reflect the new number of positional param‐
24       eters.
25
26       The  value n shall be an unsigned decimal integer less than or equal to
27       the value of the special parameter '#'.  If n is not given, it shall be
28       assumed  to  be 1. If n is 0, the positional and special parameters are
29       not changed.
30

OPTIONS

32       None.
33

OPERANDS

35       See the DESCRIPTION.
36

STDIN

38       Not used.
39

INPUT FILES

41       None.
42

ENVIRONMENT VARIABLES

44       None.
45

ASYNCHRONOUS EVENTS

47       Default.
48

STDOUT

50       Not used.
51

STDERR

53       The standard error shall be used only for diagnostic messages.
54

OUTPUT FILES

56       None.
57

EXTENDED DESCRIPTION

59       None.
60

EXIT STATUS

62       If the n operand is invalid or is greater than "$#", this may  be  con‐
63       sidered  a  syntax  error  and a non-interactive shell may exit; if the
64       shell does not exit in this case,  a  non-zero  exit  status  shall  be
65       returned. Otherwise, zero shall be returned.
66

CONSEQUENCES OF ERRORS

68       Default.
69
70       The following sections are informative.
71

APPLICATION USAGE

73       None.
74

EXAMPLES

76       $ set a b c d e
77       $ shift 2
78       $ echo $*
79       c d e
80

RATIONALE

82       None.
83

FUTURE DIRECTIONS

85       None.
86

SEE ALSO

88       Section 2.14, Special Built-In Utilities
89
91       Portions  of  this text are reprinted and reproduced in electronic form
92       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
93       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
94       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
95       cal  and  Electronics  Engineers,  Inc  and  The  Open Group.  (This is
96       POSIX.1-2008 with the 2013 Technical Corrigendum  1  applied.)  In  the
97       event of any discrepancy between this version and the original IEEE and
98       The Open Group Standard, the original IEEE and The Open Group  Standard
99       is  the  referee document. The original Standard can be obtained online
100       at http://www.unix.org/online.html .
101
102       Any typographical or formatting errors that appear  in  this  page  are
103       most likely to have been introduced during the conversion of the source
104       files to man page format. To report such errors,  see  https://www.ker
105       nel.org/doc/man-pages/reporting_bugs.html .
106
107
108
109IEEE/The Open Group                  2013                            SHIFT(1P)
Impressum