A brief talk on the bash scripting programming variables

Source: Internet
Author: User

Bash (GNU Bourne-again Shell) is a Unix shell written for the GNU program, which is the default shell used by many Linux platforms.

Variables for bash scripting:

1. $BASH

Represents the path of a bash binary program file

Eg: Edit the bash file, such as 1.sh, in which the following code is entered:

Then save the run and the path to the bash script interpreter will appear.


2. $FUNCNAME

Represents the name of the current function

Eg: Edit bash file 2.sh, where you enter the following code:

The results of running the bash file are as follows:

$FUNCNAME acts in the body of a function, the scope of the function is exceeded to become a null value.


3. $IFS

Represents the internal domain delimiter

Eg: Edit bash file 3.sh and enter the following code:

Then save the code to run the following results:



4. $REPLY

When no parameter variable is supplied to the Read command, the variable is supplied to the Read command as a default variable. It can also be used with the Select menu, but only the number of the selected variable, not the value of the variable itself.

Eg: Edit bash file 4.sh and enter the following code:

Save and run to get the following results (the Yellow line part of the content is keyboard input!!!) ):

As you can see from the results, $reply will be supplied to the Read command as the default variable, so the output value of the subsequent $reply is still the value entered when Read!!!



A brief talk on the bash scripting programming variables

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.