Get the App
SLTechnology News&Howtos  ›  Servers  › 

What is the meaning of the variable parameter $in Linux

Shulou Source: shulou.com Published: 2022-06-01 17:30:15 11月16日 Update

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.

Tags: Scripts parameters variables meaning content skills knowledge errors differences concise concise number location name command character string that is meaning article Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology MariaDB Huawei vpn Linux