100 Useful Command-Line Utilities

by Oliver; 2014

79. shift

As in Perl and many other languages, shift pops elements off the array of input arguments in a script. Suppose tmpscript is:
#!/bin/bash
echo $1
shift
echo $1
Then:
$ ./tmpscript x y
x
y
Refer to An Introduction to the Command-Line (on Unix-like systems) - Arguments to a Script to see how to use shift to make an input flag parsing section for your script.

<PREV   NEXT>