Linux Shell Parameters

Source: Internet
Author: User

InShellProgramming.You can use parameters.ShellLocation and Internal Parameters

1 ,Location parameters The parameters provided by the system are called location parameters. The value of the location parameter can be used $ N Get, N Is a number. 1 , That is $1. Similar C Array in language, Linux Segment the input command string and label each segment. 0 Start. The 0 No.ProgramName, from 1 It indicates the parameter passed to the program at the beginning. For example $0 Indicates the program name, $1 Indicates the first parameter passed to the program, and so on. 2,Internal Parameters In the above process$0Is an internal variable, it is required, and$1It is optional. And$0The same internal variables include the following. $ #----Total number of parameters passed to the program $? ----PreviousCodeOrShellProgram inShell. If it Exits normally, return0And vice versa0Value. $ *----A string consisting of all parameters passed to the program. The following is an example. [Root @ server TMP] # Cat test. Sh #! /Bin/bash # Test shell Echo $0 Echo $1 Echo $2 Echo $? Echo $ * Echo $ # [Root @ server TMP] #./test. Sh yema bhanv Edu Network ./Test. Sh // program name Yema // The first parameter Bhanv // The second parameter 0 // program execution result Yema bhanv Edu network // string consisting of passing Parameters 4 // number of parameters

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.