In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail the mobile position parameters using the shift command of linux. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
The shift command is used to move parameters (move to the left), and is usually used to iterate through each parameter in turn without knowing the number of parameters passed in and then process them accordingly (common in startup scripts of various programs in Linux).
For a command-line argument, the number of arguments can be variable, but you can loop through $* or $@. If the user asks Shell to process the parameters one by one without knowing the number of variables, that is, $2 after $1 and $3 after $2. $1 is available before running the shift command, but after using the shift command, the original $2 becomes $1, the original $1 becomes unavailable, and the number of parameters obtained by the $# command is reduced by 1.
Syntax format: shift [parameters]
Common parameters:
Reference example
Read the input parameters in turn and print the number of parameters:
The run.sh content is as follows:
#! / bin/bashwhile [$#! = 0] Doecho "the first parameter is: $1, the number of parameters is: $#" shiftdone enter the following command to run: the run.sh a b c d e f result is as follows: the first parameter is: a, the number of parameters is: 6 the first parameter is: B, the number of parameters is: 5 the first parameter is: C, the number of parameters is: 4 the first parameter is: d, the number of parameters is: 3 the first parameter is: e The number of parameters is: 2 the first parameter is: F, the number of parameters is: 1
Move the parameters to the left by 3:
#! / bin/bashecho-e ". / t.sh arg1 arg2 arg3 arg4 arg5 arg6" str1= "${1}, ${2}, ${3}" echo "str1=$str1" shift 3str2=$@echo "str2=$str2" sh t.sh 1 2 3 4 5 6 7 str1 penny 3
Move the parameters one by one from left to right:
[root@linuxcool ~] # cat shift.shroud doecho doecho "the first parameter is: $1 the number of parameters is: $#" shifts [root @ linuxcool] # sh shift.sh Lily Lucy Jake Mike the first parameter is: the number of Lily parameters is: 4 the first parameter is: the number of Lucy parameters is: 3 the first parameter is: the number of Jake parameters is: 2 the number of parameters is: 1 So much for sharing the mobile location parameters using the shift command of linux I hope the above content can be of some help to you and learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.