introduces the concept of shell programming and variable definitions - about the relationship between script and shell process

shell is a user interface to interact with the kernel, the most popular shell is called bash shell

shell is also a programming language <interpreted programming language>, that is a shell script <is to use the command shell linux programming>

There may be more than a system shell, you can view the shell command system installed by cat / etc / shells, shell command syntax may support different is not the same

The basic format

Code written in plain text files, usually .sh suffix name

Example vi hello.sh:

#! / Bin / bash ## expressed what kind of shell parser to parse the implementation of our program this script

echo  "hello world"

Execute the script: sh hello.sh

X permissions or add to the script, direct the implementation of: chmod + x hello.sh

                                                    ./hello.sh

System Variables

linux shell variables into "system variables" and "user-defined variables"

You can view the system variables set command

Custom Variables

Variable = value, equal on both sides with no spaces Example: STR = abc

Variable names are generally accustomed to uppercase

Use variables: $ arg

Double and single quotes are different, only the double quotes space off Italy, the single quotation marks will be variable reference such as $ param off Italy

A revocation of the unset variable A

readonly B = 2 declare a static variable B = 2, can not unset

export A variable can be upgraded to the current shell process in a global environment variables, use the program for other sub-shell

A shell process can not be promoted to their own definition of variables to the parent process space, and space can only access the child process the parent process with export-defined variables. "" No. When executing the script, the script will let the caller is located in the shell execution process space

Guess you like

Origin www.cnblogs.com/chengting/p/11515700.html