Dollar sign in Linux Shell $

Source: Internet
Author: User

The dollar sign ($) is often used in Linux. The following is what they represent:
$0 shell command itself (including the full path)
$1 to $9 indicates the shell Parameters
$ # Number of parameters passed to the script
$ * Display all parameters passed to the script with a single string
$ ID of the script run
$! ID of the last process running in the background
$ @ Is the same as $.
$-Display the current options used by shell.
$? Displays the execution status of the last command. 0 indicates no error.

For example:

Test. ShCode

#! /Bin/bashecho "\ $0 is:" $0 echo "\ $1 is:" $1 echo "\ $2 is:" $2 Echo "\ $ * is: "$ * echo" \ $ @ is: "$ @ echo" \ $ # is: "$ # echo" \ $! Is: "$! Echo "\ $ is:" $ echo "\ $? Is: "$?

Execution output:

$ Sudo. /test. sh P1 P2 $0 is :. /test. sh $1 is: P1 $2 is: P2 $ * is: P1 P2 $ @ is: P1 P2 $ # Is: 2 $! Is: $ is: 3469 $? Is: 0

Reference: http://blog.csdn.net/lovingprince/article/details/6332636

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.