A script to understand the meaning of positional parameters in a shell script

Source: Internet
Author: User

#!/bin/bash
Echo ' $ "gets the currently executing shell script file name: '" $ "
Echo ' $n gets the nth parameter value of the currently executing shell script, n=1..9 ' $ ' =$1, ' $ $ ' =$2, ' $ $ ' =$3
Echo ' $ get all parameters for the current shell ... Note the difference from [email protected]: ' $
Echo ' $# gets the total number of parameters in the current shell command line: ' $#
Echo ' $$ gets the current shell's process number (PID): ' $$
Sleep 3 &
Echo ' $! PID that executes the previous instruction: ' $!
Echo ' $? Gets the return value of the last instruction executed: ' $?
Echo ' [email protected] Get all the parameters of the current Shell "$" "$" "$" "...": ' [email protected]
Echo ' $ before the last parameter of the command or script: ' $
Eof

SH positional.sh a b c d E

$ A Gets the currently executing shell script file name: positional.sh
$n gets the nth parameter value of the currently executing shell script, n=1..9 $1=a,$2=b,$3=c
$* get all the parameters of the current shell ... Note the difference from [email protected]: a b c D E
$# gets the total number of parameters in the current shell command line: 5
$$ gets the current shell's process number (PID): 1979
$! Executes the pid:1980 of the previous instruction
$? Gets the return value of the last instruction executed: 0
[email protected] Get all the parameters of the current Shell "$" "$" "$" "...": a b C D E
$_ the last parameter of the preceding command or script: E

A script to understand the meaning of positional parameters in a shell script

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.