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 > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article shows you how to analyze the meaning of shell variables $#, $@, $0 in linux. The content is concise and easy to understand. It will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
The meaning of the shell variables $#, $@, $0 in linux is explained as follows:
Variable description:
$
PID (ProcessID) of Shell itself
$!
The PID of the background Process that the Shell last ran
$?
The end code of the last run command (return value)
$-
Flag list set using the Set command
$*
List of all parameters. In the case of "$*" enclosed by "$", with "$1 $2". Outputs all parameters in the form of $n ".
$@
List of all parameters. In the case of "$@" surrounded by ", output all parameters in the form of" $1 "" $2 "…" $n ".
$#
Number of parameters added to Shell
, 0
The file name of the Shell itself
$1 million
The parameter values added to the Shell. $1 is the first parameter, $2 is the second parameter.
Example:
1 #! / bin/bash 2 # 3 printf "The complete list is% s\ n"$$" 4 printf "The complete list is% s\ n"$!" 5 printf "The complete list is% s\ n" $? "6 printf" The complete list is% s\ n "$*" 7 printf "The complete list is% s\ n" $@ "8 printf" The complete list is% s\ n "$#" 9 printf "The complete list is% s\ N "$0" 10 printf "The complete list is% s\ n"$1" 11 printf "The complete list is% s\ n" $2
Results:
[Aric@localhost] $bash params.sh 123456 QQThe complete list is 24249The complete list isThe complete list is 0The complete list is 123456 QQThe complete list is 123456The complete list is QQThe complete list is 2The complete list is params.shThe complete list is 123456The complete list is QQ the above is how to analyze the meaning of the shell variable $#, $@, $0 in linux. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
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.