026_ about special variables in the shell $ $n $* $@ $! $?

Source: Internet
Author: User

One

$n: Gets The nth argument of the current shell script, n=1..9, when n is 0, represents the file name of the script, if n is greater than 9, enclosed in curly braces like${10}.

$*: Gets all parameters of the current shell and treats all command-line arguments as a single string.
[Email protected]: All parameters of this program "$" "$" "$" "...", this is the best way to pass parameters to other programs, so TA retains any whitespace embedded in each parameter.
$#: Gets the total number of parameters in the current shell command line.

$_: Represents the last parameter of the previous command

eg

Cat Test.sh#!/bin/bashecho $_

SH test.sh 1 2 3 4 5
/bin/sh

$!: PID representing the last executed background command

eg

?  Agent git: (master)? Nohup./falcon-agent-  c  cfg.json &> var/app.log &[1] 76901?  Agent git: (master)? Ps-p $!  PID TTY time           CMD76901 ttys000    0:00.01./falcon-agent-c Cfg.json?  Agent git: (master)? echo $!76901?  Agent git: (master)? Ps-p $!  PID TTY time           CMD76901 ttys000    0:00.02./falcon-agent-c Cfg.json?  Agent git: (master)? Echo $!76901

? Agent git: (master)? Nohup Sh./test.sh &
[2] 79469
Appending output to Nohup.out
? Agent git: (master)? Echo $!
79469

Two

Reference: http://www.111cn.net/sys/linux/79750.htm

026_ about special variables in the shell $ $n $* [email protected] $! $?

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.