Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the meaning of the variable parameter $in Linux

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article shows you what the variable parameter $means in Linux. The content is concise and easy to understand. It will definitely make your eyes shine. I hope you can gain something through the detailed introduction of this article.

Meaning of Linux variable parameter $

Let's write a simple script first and explain the meaning of each variable after execution # touch variable# vi variable The script reads as follows: #!/ bin/shecho "number:$#"

echo "scname:$0"

echo "first :$1"

echo "second:$2"

echo "argume:$@"

echo "show parm list:$*"

echo "show process id:$$"

echo "show precomm stat: $?"

Save Exit Grant Script Execution Permission # chmod +x variable Execute Script #./ variable aa bbnumber:2

scname:。/ variable

first:aa

second:bb

argume:aa bbshow parm list:aa bb

show process id:24544show precomm stat:0

As you can see from the display: $#is the number of parameters passed to the script $0 is the name of the script $1 is the first parameter passed to the shell script $2 is the second parameter passed to the shell script $@ is a list of all parameters passed to the script $* is a single string showing all parameters passed to the script, unlike the positional variable, which can have more than 9 parameters $is the ID number of the current process the script runs $? Yes Displays the exit status of the last command, 0 indicates no errors, others indicate errors

What does the variable parameter $mean in Linux? Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserves, please pay attention to 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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report