Script sh05. SH
#!/bin/bash# program# Program shows the effect ofShift function# history:# -/9/6ZENGDP First Releasepath=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/Binexport PATHEcho "Total parameter number is ==> $#"Echo "whole parameter is ==> ' [email protected] '"ShiftEcho "Total parameter number is ==> $#"Echo "whole parameter is ==> ' [email protected] '"Shift 3Echo "Total parameter number is ==> $#"Echo "whole parameter is ==> ' [email protected] '"
Run sh sh05. SH One, three four five six
Get
Total parameter number is ==> 6 you Whole P Arameter is ==> " one-Three four fi ve six " total parameter number is = = = 5 you whole parameter is ==>
'
Just look at the results and you'll know, that shift shifts the variables, and the shift can be followed by numbers, representing the meaning of taking away the first few arguments. In the results above, the first shift followed by his display is "one two three four five six", so there are five left! The second time take three directly, become "two three four five six"! Can this case be understood? Do you understand the function of shift?
Shift Move Variable