Shell programming-first know shell


Classification of programming languages:

Compiled language : Run compiled language is relative to interpreted language. Compiled language first compiles the source code to generate machine language, and then the machine runs the machine code (binary). Like C/ C++etc are all compiled languages.
Interpreted language : In contrast to compiled languages, the source code is not directly translated into machine language, but first translated into intermediate code, and then the intermediate code is interpreted and run by the interpreter. For example, Python/ JavaScript/ Perl/ Shellare all interpreted language.
Difference : the former can be run on the platform after the source program is compiled, and the latter is compiled during runtime. So the former runs fast, and the latter has good cross-platform performance.

shell definition

Shell 也是一种程序设计语言,它有变量,关键字,各种控制语句,
有自己的语法结构,利用shell程序设计语 言可以编写功能很强、代码简短的程序。

Parent shell and child shell

Shell can be divided into parent shell and sub shell:
parent shell :
after logging in to the system, the default is the parent shell bash shell
loading process

~/.bash_profile --> ~/.bashrc --> /etc/bashrc	 --> /etc/profile --> /etc/profile.d/*.sh

A subshell is
equivalent to opening a shell in the parent shell, and opening a terminal in a terminal. The variables defined by the subshell can only be used by the current shell.
Loading process

~/.bashrc --> /etc/bashrc --> /etc/profile.d/*.sh

View the currently used shell

echo $SHELL

Configure the shell

Global configuration file
/etc/profile
/etc/profile.d/*.sh
/etc/bashrc
Personal configuration file
~/.bash_profile
~/.bashrc

Create a shell script

vim hellow.sh    # hellow是脚本名称  .sh后缀表示是一个shell脚本。
1. #!/bin/bash 解释器路径
2. 
3. echo "hellow "  #在屏幕上显示hellow

Execute a shell script

1、 sh hellow.sh
2、 bash shellow.sh
3、 ./路径 hellow.sh
4、 source hellow`.sh

Guess you like

Origin blog.csdn.net/qq_26129413/article/details/111183462