In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Today, the editor shares with you the meaning of $in shell and the difference between $and $@. I believe most people don't know much about it. In order to make you understand better, the editor summed up the following content for you. Without saying much, let's read on.
#! / bin/bash#Author:Sparrow#Name:explain_shell_parameters#Date 2020-3-11#Description:#Explain what $0 $1 $2 $3 $4 $@ $* $# mean#Program begin#Ensure enter six parameters at leastif [$#-le 6]; then echo "Please enter 6 parameters at least!" Exit 1fi#Echo every $echo "\ $0-$0" echo "\ $1-$1" echo "\ $2-$2" echo "\ $3-$3" echo "\ $4-$4" echo "\ $5-$5" echo "\ $6- -$6 "echo"\ $7-$7 "echo"\ $8-$8 "echo"\ $#-$# "echo"\ $@-$@ "echo"\ $*-$* "echo"\ $? "l output the result sh Explain_shell_parameters.sh 1 2 3 4 5 6 7 "result # $0 is the script name $0-explain_shell_parameters.sh $1-1 $2-2 $3-3 $4-4 $5-5 $6- 6 $7-7 $8 $#-8 $@-1 2 3 4 5 6 7 8 $*-1 2 3 4 5 6 6 7 7 the difference between $?-0 $* and $@ when $* And $@ are not surrounded by double quotes "" There is no difference between them, each parameter received is treated as a piece of data, separated by spaces from each other. But when they are enclosed in double quotes, there is a difference: "$*" treats all parameters as a piece of data as a whole, rather than each parameter as a piece of data. "$@" still treats each parameter as a piece of data, independent of each other. For example, if five parameters are passed, for "$*", the five parameters will be merged together to form a piece of data, which can not be separated; for "$@", the five parameters are independent of each other. They are five pieces of data. If you use echo to output "$*" and "$@" directly, you can't see the difference; but if you use a for loop to output data one by one, you can immediately see the difference.
So much for the meaning of $in shell and the difference between $@ and $@. I hope the above content can be helpful to you and learn more. If you like this article, you might as well 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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.