(20) linux shell programming

1. What is the shell

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

Shell is a programming language <interpreted programming language>, that is a shell script

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

 

Implementation 2.Shell script

(1) The first: absolute or relative path input script first to be given permission to /root/helloWorld.sh ./helloWorld.sh + x

Alternatively, rather than giving + x permission, but with the interpreter interpreted sh helloworld.sh

(2) The second: bash or sh + script sh /root/helloWorld.sh sh helloWorld.sh

(3) The third: in front of the path of the script along with /root/helloWorld.sh ./helloWorld.sh "."..

Differences: first and second will open a new bash, bash the different variables can not be shared

 

3.Shell the variables

Linux Shell variables into the "system variables" and "user-defined variables", you can view the system variables set command

System variables: $ HOME, $ PWD, $ SHELL, $ USER, etc.

(1) displays all the current shell variables: set

(2) the definition of variables

Variable = value (e.g. STR = abc, A = 9)

No spaces on both sides of the equal sign

Variable names are generally accustomed to uppercase

Double and single quotes are different, only the double quotes space off Italy, single quotes will take off all special characters meaning

 

Guess you like

Origin www.cnblogs.com/paradis/p/11357216.html