Shift
The shift command can take a
numerical parameter indicating how many positions to shift.
Examples of Shift Command usage:
[ved@localhost
~]$ cat shift.sh
#!/bin/bash
echo
"$@"
shift
echo
"$@"
shift
echo "$@"
[ved@localhost
~]$ sh shift.sh 1 2 3 4 5
1 2
3 4 5
2 3
4 5
3 4 5
|
[ved@localhost
~]$ cat shift1.sh
#!/bin/bash
shift
3
echo
"$@"
exit
0
[ved@localhost
~]$ sh shift1.sh 1 2 3 4 5
4 5
|
[ved@localhost
~]$ cat shift2.sh
#!/bin/bash
n=2
shift
$n
echo
"$@"
exit
0
[ved@localhost
~]$ sh shift2.sh 1 2 3 4 5
3 4 5
|
No comments:
Post a Comment