The meaning of the variable #, @, 1, *,$$,$ in Linux __linux

Source: Internet
Author: User

$# is the number of arguments passed to the script $0 is the name of the script itself $1 is the first argument passed to the shell script $2 is passed to the shell script The second parameter $@ is a list of all parameters passed to the script $* is a single string that shows all the parameters passed to the script, unlike the position variable, The parameter can exceed 9 $$ is the current process ID number of the script run $? is to display the exit status of the last command, 0 indicates no errors, others indicate an error


Difference: @@ 和 * The same point: all refer to all parameters are different points: only in double quotes reflected. Suppose that three parameters were written when the script was run (stored in 1, 2, 3), then "*" is equivalent to "1 2 3" (passing a parameter), and "@" is equivalent to "1", "2", "3" (passed three parameters)

Example One

# #dels. Sh

echo "number:$#" echo "
scname:$0"
echo "--" echo "Second:$2" echo "
argume:$@"
echo "show Parm list:$* "
echo" show process id:$$ "
echo" show Precomm stat: $? "

Execution results

[@jihite]$ sh del.sh 1 2 3 number:3 scname:del.sh first:1 second:2 argume:1 2 3 show Parm List:1 2 3 show process ID: 21057 Show Precomm stat:0


Source:

Http://www.cnblogs.com/kaituorensheng/p/4002697.html


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.