Linux Learning note--bash scripting one variable, variable type

Source: Internet
Author: User

Bash scripting one variable, variable type

Shell Programming:

Compilers, interpreters

Programming languages: Machine language, assembly language, advanced languages

Static language: Compiled language

Strongly typed (variable) language

convert into executable format in advance

C,C + +,JAVA,C #

Dynamic Language: interpreted language On the fiy

Weak type

Edge interpretation Side Execution

ASP,asp, PHP, Shell,Python,Perl

process oriented:shell,C

Object-oriented: JAVA,Python ,Perl,C + +

Variables: Memory space, naming

Memory: Compiled storage unit

Variable type: Determine the storage format and length of the data in advance

character

value

integral type:

floating point type:

Boolean type: True, False

Logical operations: with, or, not (!) , XOR, or

Shell: weakly typed programming languages

Strongly typed: The variable must be declared beforehand before it is used, and even needs to be initialized;

Empty ( NULL)

Weak type: variable time declaration, not even type;

variable Assignment:

Bash Variable Type:

Environment type:

local variable: (local variable)

positional variables:

Special variables (System variables):

Local variables:

Varname=value : scoped to entire bash process;

Local variables:

Localvarname=valuw : The scope is the current code snippet;

environment variable: scope is current shell process and its child processes

Setexport Varname=value :

"Export"

The script starts a child shell process when it executes ;

scripts that are started on the command line inherit the current shell environment variable

scripts that are automatically executed by the system (not command-line startup) require a self-defined environment variable

Bash :

Positional variables:

$1,$2,...

Special variables:

$?: The execution status return value of the previous command;

There are two possible types of return values for program execution:

Program execution Results

Program Execution status return code (255 )

0 : Execute correctly

(1-255): Error execution,1,2,127 system reserved;

Output redirection:

: Overwrite output

>>: Append output

2>: Redirect Error output

2>>: Append method

&>: simultaneous redirection (redirected error output)

/dev/null: Soft device,bit bucket , data black hole

undo Variable:

Unset VARNAME}

View current shell The variables in:

Set

View current shell Environment Variables in:

Printenv

Env

Export

Script: The stuffing of the command, as the actual need, combined with

shebang : Magic number

# ! /bin/bash

# Comment lines , do not execute

Variable reference:${varname}, parentheses can sometimes be omitted


This article is from the "11913800" blog, please be sure to keep this source http://11923800.blog.51cto.com/11913800/1844530

Linux Learning note--bash scripting one variable, variable type

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.