Shell programming special variable -- Process status variable

Source: Internet
Author: User

Process status variable

1. $ get the current shell process ID (PID)

2. $! PID used to execute the previous command

3. $? Obtain the return value for executing the previous command (0 indicates success, and non-zero indicates failure, which is very common)

4. $ _ the last parameter of the command or script previously executed

Cat> test $. shecho '$ =' $ echo '$! = '$! Echo '$? = '$? Echo '$ @ =' $ @ echo '$ _ =' $ _ # output the following sh test \ $. sh 1 2 3 $ = 2556 $! = $? = 0 $ @ = 1 2 3


$ * And $ @

$ * Treat all parameters as a single string, equivalent to "$1 $2 $3"

$ @ Treat each parameter as a single string and retain any blank characters in the command line

Set -- 'I am' jane leefori in $ *; doecho $ I; done; Iamjaneleefori in $ @; doecho $ I; done; Iamjaneleefori in "$ @"; doecho $ I; done; I amjaneleefori in "$ *"; doecho $ I; done; I am jane lee


Related Article

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.