Built-in variables for common shell scripting

Source: Internet
Author: User

Processing of parameter processing-shell incoming parameters

    1. $#The number of arguments passed to the script
    2. $*Displays all parameters passed to the script in a single string. Unlike positional variables, this option parameter can be more than 9
    3. $$The current process ID number for the script to run
    4. $!Process ID number of the last process running in the background
    5. [email protected]With the $# same, but quoted when used, and returns each parameter in quotation marks
    6. $-Displays the current options used by the shell, same as the SET command function
    7. $?Displays the exit status of the last command. 0 means there is no error, and any other value indicates an error.
      Variable meaning
      $0Script Name
      $1Positional parameters #1
      $2- $9 Position parameter #2-#9
      ${10}Positional parameters #10
      $#Number of positional parameters
      "$*"All positional parameters (as a single string) *
      "[email protected]"All positional parameters (each as a separate string)
      ${#*}The number of command-line arguments passed to the script
      ${#@}The number of command-line arguments passed to the script
      $?return value
      $$Process ID (PID) of the script
      $-Flags passed to script (using set)
      $_Last parameter of the previous command
      $!Process ID (PID) of the last job running in the background

Built-in variables for common shell scripting

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.