当前位置:网站首页>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
边栏推荐
- Directory related commands
- 【观察】智能产业加速,为何AI算力要先行?
- [Title brushing] avoid flooding
- Optimization of unit test efficiency: why test programs? What are the benefits of testing?
- 第四批入围企业公示——年度TOP100智能网联供应商评选
- Tencent two sides: @bean and @component are used on the same class. What happens?
- Assertions of regular series
- [the path of system analyst] Chapter 5 Software Engineering (Agile Development)
- Prometheus 2.29.0 new features
- 为基础性语言摇旗呐喊
猜你喜欢
腾讯二面:@Bean 与 @Component 用在同一个类上,会怎么样?
【C】 In depth understanding of pointers and callback functions (Introduction to simulating qsort)
【刷题篇】避免洪水泛滥
科普达人丨漫画图解什么是eRDMA?
Tencent two sides: @bean and @component are used on the same class. What happens?
Google Earth Engine(GEE)——将字符串的转化为数字并且应用于时间搜索( ee.Date.fromYMD)
Deep understanding Net (2) kernel mode 4 Summary of kernel pattern constructs
[scientific research data processing] [practice] frequency analysis chart of category variables, distribution chart of numerical variables and normality test (including lognormal)
QQ 居然被盗了?原因在这......
单元测试效率优化:为什么要对程序进行测试?测试有什么好处?
随机推荐
I want to ask how to open an account at China Merchants Securities? Is it safe to open a stock account through the link
重磅:国产IDE发布,由阿里研发,完全开源!
Apache Doris Compaction优化百科全书
Deep understanding Net (2) kernel mode 4 Summary of kernel pattern constructs
想请教一下,我在佛山,到哪里开户比较好?手机开户是安全么?
(8)JMeter元件详解之 Once only Controller 仅一次控制器
In the digital age, XDR (extended detection and response) has unlimited possibilities
知识传播不能取代专业学习!
用Unity实现Flat Shading
How can I protect my private key?
[the path of system analyst] Chapter 5 Software Engineering (Agile Development)
可觀測,才可靠:雲上自動化運維CloudOps系列沙龍 第一彈
Talk about Vue's two terminal diff algorithm, analysis of the rendering principle of the mobile terminal, and whether the database primary key must be self incremented? What scenarios do not suggest s
【科学文献计量】外文文献及中文文献关键词的挖掘与可视化
服务线上治理
Golang template (text/template)
【观察】智能产业加速,为何AI算力要先行?
深入理解.Net中的线程同步之构造模式(二)内核模式3.内核模式构造物Mutex
What network security problems are exposed when a large-scale QQ number theft event occurs?
Introduction to two types of rxjs observable operators