Pages

Saturday, April 15, 2017

Shift Command

Shift Command is basically used to move the command line arguments to left. In shell scripting the maximum no. of command line parameters becomes 9. If we want to get more than 9 parameters we use the shift command.

[user@ XXXXX]# cat myscript.sh
#!/bin/bash
echo "Input: $@"
shift 3
echo "After shift: $@"

[user@ XXXXX]# sh myscript.sh one two three four five six

Input: one two three four five six
After shift: four five six

No comments:

Post a Comment