当前位置:网站首页>Shell programming overview
Shell programming overview
2022-06-30 14:01:00 【Upward Wolf】
One 、Shell A term is used to explain
1.1、Kernel
1.2、Shell
- command interpreter (command interpreter)
- Shell It's a use. C A program written in a language , It is used by users Linux The bridge .Shell It's a command language , Another programming language .
- Shell It's an application , This application provides an interface , Through this interface, users can access the operating system Nuclear services .
1.3、shell Two main trends
- sh:
- Bourne shell(sh) ,Solaris,hpux Default shell
- Bourne again shell(bash) ,Linux System default shell
- csh:
- C shell(csh)
- tc shell(tcsh)
1.4、#! Statement

Two 、Shell Script execution
2.1、 Enter the absolute or relative path of the script
Check whether the file has execution permission , If not , You can give it permission .
- /root/helloworld.sh
- ./helloworld.sh
- It must be an executable file
2.2、bash or sh + Script
- sh helloworld.sh
- When the script does not x Authority ,root And the file owner can execute normally in this way
2.3、 Add... Before the path of the script ". " or source
- source helloworld.sh
2.4、 difference
- The first and the second will open a new one bash, Different bash Variables in cannot be shared .
- The third kind of It's in the same shell What's going on inside
Demo1:




Perform process analysis :

Demo2:

The analysis reason : When you use sh hello.sh perform shell Script words , Because it will recreate a child process when executing this script , Data between processes cannot be shared , So the one you created earlier name= Zhang San is a variable that cannot be recognized . But if you use source hello.sh To execute the script , Because no new process is created during script execution , So it's still possible to name Variable to print .
Then how to solve it ?
The solution lies in the following keywords export
2.5、export
- You can pass the variables of the current process to the child process to use
- Future configuration profile When All variables must be preceded by export
边栏推荐
- The programming competition is coming! B station surrounding, senior members and other good gifts to you!
- Observable, seulement fiable: première bombe de salon de la série cloudops d'exploitation et d'entretien automatisés dans le nuage
- 发生QQ大规模盗号事件,暴露出什么网络安全问题?
- 表格储存中sql查询的时候,查询结果增加主键报错,查询结果超过10w行。需要对主键增加上多元索引吗?
- Flat shading with unity
- Service online governance
- How to execute a query SQL
- Assertions of regular series
- numpy 创建空数组 data = np.empty(shape=[1, 64,64,3])
- [the path of system analyst] Chapter 5 Software Engineering (Agile Development)
猜你喜欢

WTM major updates, multi tenancy and single sign on

Apache Doris Compaction优化百科全书

Loss function: Diou loss handwriting implementation

60 divine vs Code plug-ins!!

深入理解.Net中的线程同步之构造模式(二)内核模式2.内核模式构造物Semaphone

mysql拒绝访问、管理员身份打开的

SQL attendance statistics monthly report

Apache Doris comparison optimization Encyclopedia

Pytorch查看模型参数量和计算量

Step by step | help you easily submit Google play data security form
随机推荐
Basic syntax of unity script (1) - common operations of game objects
Heavyweight: the domestic ide was released, developed by Alibaba, and is completely open source!
visualstudio 和sql
SQL programming problem, test case failed
Knowledge dissemination cannot replace professional learning!
Exlipse operates on multiple rows at the same time. For example, input the same text in multiple lines and columns at the same time
Kaniko official documents - build images in kubernetes
Simple understanding of the difference between get request and post submission
想請教一下,我在佛山,到哪裏開戶比較好?手機開戶是安全麼?
Unity animator parameter
Basic syntax of unity script (2) -record time in unity
“即服务”,企业数字化转型的必然选择
[scientific research data processing] [basic] category variable frequency analysis chart, numerical variable distribution chart and normality test (including lognormal)
Observable, reliable: the first shot of cloudops series Salon of cloud automation operation and maintenance
QQ was stolen? The reason is
知识传播不能取代专业学习!
IM即时通讯应用开发中无法解决的“顽疾”
Unity Animator 参数
Step by step | help you easily submit Google play data security form
Embedded development: five C features that may no longer be prohibited