Description of special variable $0,$?,$!,$*,$#,$1~ $n of shell species

Source: Internet
Author: User

Special variables:

$?: The execution result of the previous command returns a value of 0-255,0 for execution success, and other values indicate unsuccessful execution

$!:shell PID of the last running background process

PID of the $$:shell itself

$: Script file path itself file name;

$#: The number of script parameters;

$*: all parameter lists. If "$*" is enclosed in "" ", output all parameters in the form of" $ $ ... $n "

[Email protected]: all Parameters list. such as "[email protected]" with "" "in the case, with" $ "" $ "... Output all parameters in the form "$n"

$1~ $n: Each parameter value added to the shell. $ $ is the 1th parameter, and the $ = is the 2nd parameter ...


By using the following script to demonstrate:

[[email protected] tmp]# vim test$.sh#!/bin/bash echo ' $# ' $# echo ' $ A ' $ Echo ' $ + ' echo ' $ ' $ Echo '  $ $* ' $*[[email protected] tmp]# [[email protected] tmp]#./test\$.sh 3 2 1$# 3$0./test$.sh$1 3$2 2$3 1$* 3 2 1


This article is from the "Wang Liming" blog, make sure to keep this source http://afterdawn.blog.51cto.com/7503144/1863912

Description of special variable $0,$?,$!,$*,$#,$1~ $n of shell species

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.