5:02 PM Shift command with examples |
shift - shift command is used to shift positional parameters FORMAT DESCRIPTION
The value n shall be an unsigned decimal integer less than or equal to the value of the special parameter '#' . If n is not given, it is assumed to be 1. If n is 0, the positional and special parameters are not changed. Examples: Below is a simple script to understand the use of shift command: shanky@local:/home/shanky/test:> cat shifttest.sh #!/usr/bin/ksh print "All parameters before shift:$*" print "Param1=$1"; We have used "shift 2" to shift the positional parameters by 2 positions. When we execute the script, the output is as below:
You may notice that the first parameter is containing the value of 3rd positional paremters and so on.. |
|
|
Related blogs
You may also like to see:
| [2016-12-25] | [Open System-Linux] |
Guide for working with zipped and archived files in Linux/AIX | |
| [2015-08-18] | [Open System-Linux] |
How to open a PDF file or a Postscript file in Linux - Evince Document viewer? | |
| [2014-10-17] | [Open System-Linux] |
| | |
| [2017-08-13] | [Open System-Linux] |
Perl trick to remove Ctrl - M charater from a file | |
| [2015-09-09] | [Open System-Linux] |
Some funny and cool commands in Linux | |
| Total comments: 0 | |
Guide for working with zipped and archived files in Linux/AIX
How to open a PDF file or a Postscript file in Linux - Evince Document viewer?
Perl trick to remove Ctrl - M charater from a file
Some funny and cool commands in Linux