当前位置:网站首页>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
边栏推荐
猜你喜欢

60 divine vs Code plug-ins!!

【刷题篇】避免洪水泛滥

Apache Doris comparison optimization Encyclopedia

用Unity实现Flat Shading

QQ 居然被盗了?原因在这......

This article explains the concepts of typed array, arraybuffer, typedarray, DataView, etc

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

Optimization of unit test efficiency: why test programs? What are the benefits of testing?

腾讯二面:@Bean 与 @Component 用在同一个类上,会怎么样?
![[Title brushing] heater](/img/ee/70e122b1b1a406624aa7c6442fcdc1.png)
[Title brushing] heater
随机推荐
Deep understanding Net (2) kernel mode 3 Kernel mode construct mutex
Yousi College: Six Sigma is not just statistics!
Rpm2rpm packaging steps
知识传播不能取代专业学习!
Dart 扩展特性
Paper interpretation (AGC) attributed graph clustering via adaptive graph revolution
Publicity of the fourth batch of shortlisted Enterprises - annual Top100 smart Internet supplier selection
Waving flags and shouting for basic language
2022-06-23 sail soft part formula and SQL generation (month and quarter retrieval)
How does MySQL merge columns?
I'd like to ask you, where can I open an account in Foshan? Is it safe to open a mobile account?
可观测,才可靠:云上自动化运维CloudOps系列沙龙 第一弹
Google Earth Engine(GEE)——GHSL:全球人类住区层,建成网格 1975-1990-2000-2015 (P2016) 数据集
Step by step | help you easily submit Google play data security form
Methodology for troubleshooting problems (applicable to troubleshooting problems arising from any multi-party cooperation)
QQ was stolen? The reason is
“即服务”,企业数字化转型的必然选择
Apache Doris Compaction优化百科全书
步骤详解 | 助您轻松提交 Google Play 数据安全表单
半导体动态杂谈