Bash script programming variable one

Source: Internet
Author: User

Bash Variable type

Environment variables

Local variables (local variables)

Positional variables

Special variables


Local variables:

Varname=valoe: scope for the entire bash process

Local variables:

Local Varname=valoe: Scope is the current code snippet

Environment variables:

Similar to local variable: scope is the current shell process and its child processes

Export Varname=valoe

Positional variables:

$ =

Special variables:

$?: Execution status return value of previous command

Program execution, there are two types of possible return values:

1. Program execution Results

2. Program Status return code (0-255)

0: Indicates proper execution

1-255: Indicates error execution, 1,2,127 system reserved

Undo Variable:

Unset VARNAME

View variables in the current shell

Set

View environment variables in the current shell

Printenv

Env

Export


The script starts a child shell process when it executes

command-line-initiated scripts inherit the current shell's environment variables

Scripts that are automatically executed by the system do not inherit and need to be self-defined environment variables


Script: Command stack, according to the actual needs, combined with the command flow control mechanism to implement the source program

The first line of the script must define its execution shell example: #!/bin/bash

This article is from the "Carey" blog, make sure to keep this source http://careygg.blog.51cto.com/11084669/1734136

Bash script programming variable one

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.