Usage of $ in Linux shell

Source: Internet
Author: User

The following lists the common methods of $

$n         represents the arguments passed to the script, representing the first one, and the second one ...
$#        represents the number of arguments passed to the script
$0          represents the name of the script.
$?         indicates the exit status of the last command, success is 0, otherwise 1
$$         indicates the ID number of the current program process
$!         represents the ID number of the last program process
[email  protected]       all parameters passed to the script

illustrate:

[email protected]:~$ VI 1. SH
#!usr/bin/bash-x
#!usr/bin/bash-x

echo "$$"
#!usr/bin/bash-x
Echo "$", "$";
echo "$#"
Echo "$"
test-e xyy.py
echo "$?"
echo "$$"
echo "[email protected]"

Plus permissions:

[email protected]:~$ chmod 777 1.sh

The corresponding output is as follows:

[email protected]:~$ bash 1.sh a b
a,b   
2
1.sh
1
4436
a b< /p>

Usage of $ in Linux shell

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.