Книга: Fedora™ Unleashed, 2008 edition
The shift Statement
The shift
Statement
The shift
statement is used to process the positional parameters, one at a time, from left to right. As you'll remember, the positional parameters are identified as $1
, $2
, $3
, and so on. The effect of the shift
command is that each positional parameter is moved one position to the left and the current $1
parameter is lost.
The shift
statement is useful when you are writing shell programs in which a user can pass various options. Depending on the specified option, the parameters that follow can mean different things or might not be there at all.
The format of the shift
command is as follows:
shift number
The parameter number
is the number of places to be shifted and is optional. If not specified, the default is 1
; that is, the parameters are shifted one position to the left. If specified, the parameters are shifted number
positions to the left.
- Special Statements: for, while, and Others
- The if Statement
- The case Statement
- The break and exit Statements
- if-else Statement
- 4.4.4 The Dispatcher
- About the author
- Chapter 7. The state machine
- Appendix E. Other resources and links
- Example NAT machine in theory
- The final stage of our NAT machine
- Compiling the user-land applications