安徽理工大学:《Linux开发基础 Development Foundation on Linux OS》课程教学资源(PPT课件讲稿)Section 1 Shell编程 Shell programming on Linux OS

专藏理工大学 1945 ANHUI UNIVERSITY OF SCIENCE TECHNOLOGY Linux开发基础 Development Foundation on Linux OS 方贤进,Ph.D&Associate Prof. 安徽理工大学计算机科学与工程学院 1
1 安徽理工大学 计算机科学与工程学院 Linux开发基础 Development Foundation on Linux OS 方贤进, Ph.D & Associate Prof

安藏理工大学 ANHUI UNIVERSTTY OF SCIENCE TECHNOLOGY Section 1 Shell programming on Linux OS 3
3 Section 1 Shell programming on Linux OS

安藏理工大学 ANHUI UNIVERSITY OF SCIKNCE TECHNOLOGY 1.1 What is Shell? Shell is a command interpreter; Shell is a programming language,which includes variable,keywords and all kinds of control sentences; The generic Shell on Unix OS is Bourne Shell (for short,sh) There are other kinds of shell,C-shell, Korn Shell,etc. 4
4 1.1 What is Shell? ◼ Shell is a command interpreter; ◼ Shell is a programming language, which includes variable, keywords and all kinds of control sentences; ◼The generic Shell on Unix OS is Bourne Shell (for short, sh). ◼There are other kinds of shell,C-shell, Korn Shell, etc

安藏理工大学 ANHUI UNIVERSTTY OF SCIENCE TECHNOLOGY 1.2 How to create and execute shell script? Create a shell Script using VI editor For example: $vi test Where vi is an editor,test is the file name of shell script. 5
5 1.2 How to create and execute shell script? ◼Create a shell Script using VI editor For example: $vi test Where vi is an editor, test is the file name of shell script

安藏理工大学 ANHUI UNIVERSITY OF SCIENCE TECHNOLOGY 1.2 How to create and execute shell script? To execute a shell Script 1Using input redirection.Let "sh"read commands from shell script filename.E.g. $sh test 2 Script filename is used as arguments of "sh"command.E.g.: $sh script filename [script arguments] 3 Script file is set as "execute attribute",then it can execute directly $chmod +x test $./test 6
6 1.2 How to create and execute shell script? ◼ To execute a shell Script ① Using input redirection. Let “sh” read commands from shell script filename. E.g. $sh < test ② Script filename is used as arguments of “sh” command. E,g.: $sh script filename [script arguments] ③ Script file is set as “execute attribute”, then it can execute directly $chmod +x test $./test

安藏理工大学 ANHUI UNIVERSITY OF SCIENCE TECHNOLOGY 1.3 shell中的变量 1.3.1 Environment variables ①可写的环境变量 在用户登陆的过程中执行/etc/profile文件进行初始化 ■各个用户自身的启动文件/home/username/.bash profile 可通过set命令显示当前己经设置的环境变量及其值。 7
7 1.3 shell中的变量 1.3.1 Environment variables ①可写的环境变量 ◼ 在用户登陆的过程中执行/etc/profile文件进行初始化 ◼ 各个用户自身的启动文件/home/username/.bash_profile 可通过set命令显示当前已经设置的环境变量及其值

安藏理工大学 ANHUI UNIVERSITY OF SCIKNCE TECHNOLOGY 1.3 shelli中的变量 1.3.1 Environment variables ②只读的环境变量 环境变量 含义 $0 Shell script filename $1~$9 First-ninth command line arguments $* All value of command line arguments $# The number of command line arguments $$ The current process ID $? The exit status of the last command,"O"indicates "success","1"indicates "failure" $刺 the process ID of the last background process Shift < Shift position argument 8
8 1.3 shell中的变量 1.3.1 Environment variables ②只读的环境变量 环境变量 含义 $0 Shell script filename $1~$9 First-ninth command line arguments $* All value of command line arguments $# The number of command line arguments $$ The current process ID $? The exit status of the last command, “0” indicates “success”, “1” indicates “failure” $! the process ID of the last background process Shift <> Shift position argument

安藏理工大学 ANHUI UNIVERSTTY OF SCIENCE TECHNOLOGY 1.3 shelli中的变量 1.3.2 Shell variables defined by Users ■definition: Variable name=string #delimiter may not be used ■citation √$variable name √As a part of a string #at the end of a string string $variable name #at the head of a string or in the middle of a string string1$(variable name)string2 9
9 1.3 shell中的变量 1.3.2 Shell variables defined by Users ◼definition: Variable name=string #delimiter may not be used ◼citation ✓$variable name ✓As a part of a string #at the end of a string ✓string $variable name #at the head of a string or in the middle of a string ✓string1${variable name}string2

安藏理工大学 ANHUI UNIVERSTTY OF SCIENCE TECHNOLOGY 1.4shel川中的特殊字符 1.4.1 Wildcard characters in Shell ■星号* ■问号? ■一对方括号[] 其作用是匹配该字符组所限定的任何一个字符,例如: f[abcd]可以匹配fa,fb,fc,fd f[a-d]与f[abcd]作用相同 ■感叹号 表示否定,例如fa-d].c表示以f打头、第二个字符不是a-d的.c文件名 10
10 1.4 shell中的特殊字符 1.4.1 Wildcard characters in Shell ◼ 星号* ◼问号? ◼一对方括号[ ] 其作用是匹配该字符组所限定的任何一个字符,例如: f[abcd]可以匹配fa,fb,fc,fd f[a-d]与f[abcd]作用相同 ◼感叹号 表示否定,例如f[!a-d].c表示以f打头、第二个字符不是a-d的.c文件名

安藏理工大学 ANHUI UNIVERSITY OF SCIENCE TECHNOLOGY 1.4shel‖中的特殊字符 1.4.2Shel中的引号 双引号” 由它括起来的字符,除$,`,仍保留其特殊功能外,其余字符通常作为普通 字符 ■单引号” 由它括起来的所有字符或字符串都作为普通字符出现。 ■倒引号 由此括起来的字符串被shel解释为命令行,其执行结果取代整个倒引号部 分。例如: Secho current directory is pwd 如果当前工作目录为home/wang的话则输出结果为 current directory is /home/wang 11
11 1.4 shell中的特殊字符 1.4.2 Shell中的引号 ◼ 双引号”” 由它括起来的字符,除$, `, \仍保留其特殊功能外,其余字符通常作为普通 字符 ◼单引号’’ 由它括起来的所有字符或字符串都作为普通字符出现。 ◼倒引号`` 由此括起来的字符串被shell解释为命令行,其执行结果取代整个倒引号部 分。例如: $echo current directory is `pwd` 如果当前工作目录为/home/wang的话则输出结果为 current directory is /home/wang
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 清华大学出版社:《智能技术》课程教学资源(PPT课件讲稿)第8章 机器学习 machine learning.ppt
- 清华大学出版社:《智能技术》课程教学资源(PPT课件讲稿)第4章 模糊逻辑技术 fuzzy logic(编著:曹承志).ppt
- 清华大学出版社:《智能技术》课程教学资源(PPT课件讲稿)第6章 遗传算法(genetic algorithms,GA).ppt
- 安徽理工大学:《计算机安全与密码学 Computer Security and Cryptography》课程教学资源(课件讲稿)密钥管技术理 Key Management.pdf
- 哈尔滨工程大学:《计算机安全与密码学 Computer Security and Cryptography》课程教学资源(课件讲稿)数字签名技术 Digital Signature.pdf
- 哈尔滨工程大学:《计算机安全与密码学 Computer Security and Cryptography》课程教学资源(课件讲稿)公钥密码体制 Public Key Cryptography.pdf
- 哈尔滨工程大学:《计算机安全与密码学 Computer Security and Cryptography》课程教学资源(课件讲稿)散列函数与消息认证码 Hash and Message Authentication Code.pdf
- 哈尔滨工程大学:《计算机安全与密码学 Computer Security and Cryptography》课程教学资源(课件讲稿)序列密码 Sequential Cipher.pdf
- 哈尔滨工程大学:《计算机安全与密码学 Computer Security and Cryptography》课程教学资源(课件讲稿)分组密码 Block Cipher.pdf
- 安徽理工大学:《计算机安全与密码学 Computer Security and Cryptography》课程教学资源(课件讲稿)利用重合指数法破解Virginia加密 Breaking Virginia Encryption.pptx
- 哈尔滨工程大学:《计算机安全与密码学 Computer Security and Cryptography》课程教学资源(课件讲稿)传统密码技术 Classical cryptography.pdf
- 安徽理工大学:《计算机安全与密码学 Computer Security and Cryptography》课程教学资源(课件讲稿)Preliminary knowledge.pptx
- 《计算机安全与密码学 Computer Security and Cryptography》课程教学资源(课件讲稿)2020年上半年我国互联网网络安全监测数据分析报告.pdf
- 安徽理工大学:《计算机安全与密码学 Computer Security and Cryptography》课程教学资源(课件讲稿)Security Situation(2019).pptx
- 《计算机导论 Introduction to Computer Science》课程配套教材教学资源(参考资料)负数在计算机中的存储和计算形式.docx
- 《计算机导论 Introduction to Computer Science》课程配套教材教学资源(参考资料)C语言中int型变量表示的数的范围.docx
- 《计算机导论 Introduction to Computer Science》课程配套教材教学资源(参考资料)浮点数在内存中的表示.docx
- 清华大学出版社:《计算机导论 Introduction to Computer Science》课程配套教材教学资源(PPT课件讲稿,第3版)第9章 计算机学科方法论.ppt
- 清华大学出版社:《计算机导论 Introduction to Computer Science》课程配套教材教学资源(PPT课件讲稿,第3版)第8章 计算机领域的典型问题.ppt
- 清华大学出版社:《计算机导论 Introduction to Computer Science》课程配套教材教学资源(PPT课件讲稿,第3版)第7章 计算机系统安全知识.ppt
- 安徽理工大学:《Linux开发基础 Development Foundation on Linux OS》课程教学资源(PPT课件讲稿)Section 2、3 GNU C/C++编程(CGI programming in GNU C/C++ language).ppt
- 清华大学出版社:《GNU/Linux编程指南》参考书籍【美】K. Wall,M. Watson, M. Whitis(共39章).pdf
- 安徽理工大学:《Linux开发基础 Development Foundation on Linux OS》课程教学资源(PPT课件讲稿)Section 4 Perl programming.ppt
- 安徽理工大学:《Linux开发基础 Development Foundation on Linux OS》课程教学资源(PPT课件讲稿)Section 4 Perl编程(附Perl源代码).ppt
- 安徽理工大学:信息安全专业教学资源(讲稿)学科前沿讲座之一.pptx
- 信息安全专业参考书籍:《Mathematics for Computer Science》计算机科学数学(revised Monday 5th June, 2017,Eric Lehman、F Thomson Leighton、Albert R Meyer).pdf
- 安徽理工大学:信息安全专业教学资源(讲稿)Advance in Intrusion Detection Techniques.ppt
- 安徽理工大学:信息安全专业教学资源(讲稿)Bot、Botnet及其检测技术.pdf
- 信息安全专业教学资源(讲稿)Artificial Immune Systems——An Emerging Technology.ppt
- 信息安全专业教学资源(讲稿)Introduction to Artificial Immune Systems(AIS).ppt
- 安徽理工大学:信息安全专业教学资源(讲稿)Differential Privacy.pdf
- 信息安全专业教学资源(讲稿)An Introduction to Artificial Immune Systems(ES2001).ppt
- 安徽理工大学:信息安全专业教学资源(讲稿)信息安全学科综述 An Overview of Information Security.ppt
- 安徽理工大学:信息安全专业教学资源(讲稿)信息安全专业介绍 An Introduction to Specialty in Information.ppt
- 信息安全专业教学资源(讲稿)Malware and Artificial Immune Systems.pdf
- Computational Intelligence(Concepts to Implementations)Part 1.pdf
- 安徽理工大学:《数据结构》课程教学资源(2016计算机网络课程设计任务书).doc
- 安徽理工大学:《数据结构》课程教学资源(2018计算机专业实习设计任务书).docx
- 安徽理工大学:《数据结构》课程教学资源(PPT课件讲稿,C语言版,2018)第1章 绪论(主讲:孙克雷).pptx
- 安徽理工大学:《数据结构》课程教学资源(PPT课件讲稿,C语言版,2018)第2章 线性表.pptx