《超级计算》教学资源(参考资料)Shell编程培训(PPT讲稿)

DAWNING %暖光 科技计算表来 Shell编程 陈伟
Shell 编程 陈伟

DAWNING 多曙光 Index 件技计算 The shell of Linux Bourne Shell Programming find.and.regular.expression 。text manipulation Shell编程 2
Index • The shell of Linux • Bourne Shell Programming • find.and.regular.expression • text manipulation Shell 编程 2

DAWNING 乡暖光 The shell of Linux 科技计算素来 ·Bourne shell(sh), 。C shell(csh), ·Korn shell(ksh), 。TC shell(tcsh), Bourne Again shell (bash) Shell编程 3
The shell of Linux • Bourne shell (sh), • C shell (csh), • Korn shell (ksh), • TC shell (tcsh), • Bourne Again shell (bash) Shell 编程 3

DAWNING %曙光 DAWNING Difference between programming and计”来 scripting languages Programming languages are generally a lot more powerful and a lot faster than scripting languages.Programming languages generally start from source code and are compiled into an executable.This executable is not easily ported into different operating systems. A scripting language also starts from source code,but is not compiled into an executable.Rather,an interpreter reads the instructions in the source file and executes each instruction.Interpreted programs are generally slower than compiled programs.The main advantage is that you can easily port the source file to any operating system. Shell编程 4
Difference between programming and scripting languages – Programming languages are generally a lot more powerful and a lot faster than scripting languages. Programming languages generally start from source code and are compiled into an executable. This executable is not easily ported into different operating systems. – A scripting language also starts from source code, but is not compiled into an executable. Rather, an interpreter reads the instructions in the source file and executes each instruction. Interpreted programs are generally slower than compiled programs. The main advantage is that you can easily port the source file to any operating system. Shell 编程 4

DAWNING 乡曙光 料技计算未来 The first bash program We must know how to use a text editor.There are two major text editors in Linux: -vi,emacs (or xemacs). So fire up a text editor;for example: -$vi& and type the following inside it: -#!/bin/bash echo "Hello World" The first line tells Linux to use the bash interpreter to run this script. We call it hello.sh.Then,make the script executable: -chmod 700 hello.sh -$1s-1 -rwx------hello.sh Shell编程 5
The first bash program • We must know how to use a text editor. There are two major text editors in Linux: – vi, emacs (or xemacs). • So fire up a text editor; for example: – $ vi & and type the following inside it: – #!/bin/bash echo “Hello World” • The first line tells Linux to use the bash interpreter to run this script. We call it hello.sh. Then, make the script executable: – $ chmod 700 hello.sh – $ ls –l -rwx------ hello.sh Shell 编程 5

DAWNING 多曙光 The first bash program To execute the program: -hello.sh -bash:hello.sh:command not found The home directory (where the command hello.sh is located) is not in the variable PATH echo SPATH bin:/usr/bin:... We must specify the path of hello.sh -$/home/srinaldi/Scripts/hello.sh -$./hello.sh Shell编程 6
The first bash program • To execute the program: – $ hello.sh -bash: hello.sh: command not found The home directory (where the command hello.sh is located) is not in the variable PATH – echo $PATH :bin:/usr/bin:… We must specify the path of hello.sh – $/home/srinaldi/Scripts/hello.sh – $./hello.sh Shell 编程 6

DAWNING 乡曙光 科技计算素米 The second bash program We write a program that copies all files into a directory,and then deletes the directory along with its contents.This can be done with the following commands: -s mkdir trash cp trash rm -rf trash s mkdir trash Instead of having to type all that interactively on the shell,write a shell program instead: -cat trash #!/bin/bash this script deletes some files cp trash rm -rf trash mkdir trash echo "Deleted al1 filsell编程 7
The second bash program • We write a program that copies all files into a directory, and then deletes the directory along with its contents. This can be done with the following commands: – $ mkdir trash $ cp * trash $ rm -rf trash $ mkdir trash • Instead of having to type all that interactively on the shell, write a shell program instead: – $ cat trash #!/bin/bash # this script deletes some files cp * trash rm -rf trash mkdir trash echo “Deleted all files!” Shell 编程 7

DAWNING 乡曙光 科技计算来 ·#!/bin/bash#if1.sh echo -n "Enter a number 1<x 10: read num if["$num"-1t10]; then if "Snum"-gt 1 ]then echo "Snum*Snum=$(($num*$num))" else echo "Wrong insertion ! fi else echo "Wrong insertion ! fi
• #!/bin/bash # if1.sh echo -n “Enter a number 1 < x < 10: " read num if [ “$num” -lt 10 ]; then if [ “$num” -gt 1 ]; then echo “$num*$num=$(($num*$num))” else echo “Wrong insertion !” fi else echo “Wrong insertion !” fi

DAWNING 乡曙光 科技计算未来 Bourne Shell Programming Shell编程
• Bourne Shell Programming Shell 编程 74

DAWNING 曙光 Bourne Shell Programming 算未 ·Certainly the most popular shell is“bash”.Bash is the shell that will appear in the GNU operating system.Bash is an sh-compatible shell that incorporates useful features from the Korn shell (ksh)and C shell (csh). bash is not only an excellent command line shell, but a scripting language in itself.Shell scripting allows us to use the shell's abilities and to automate a lot of tasks that would otherwise require a lot of commands. Shell编程 75
Bourne Shell Programming • Certainly the most popular shell is “bash”. Bash is the shell that will appear in the GNU operating system. Bash is an sh-compatible shell that incorporates useful features from the Korn shell (ksh) and C shell (csh). • bash is not only an excellent command line shell, but a scripting language in itself. Shell scripting allows us to use the shell's abilities and to automate a lot of tasks that would otherwise require a lot of commands. Shell 编程 75
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 《超级计算》教学资源(参考资料)高性能计算环境支持讲座——MPI编程讲义(消息传递并行编程环境MPI).doc
- 《超级计算》教学资源(参考资料)MPI并行程序设计简介.ppt
- 《超级计算》教学资源(参考资料)04 Linux环境下程序开发基础.ppt
- 《超级计算》教学资源(参考资料)03 linux操作系统知识培训.pptx
- 《超级计算》教学资源(参考资料)02 武汉测地所现场集群介绍(PPTminimizer).ppt
- 上海海洋大学:信息学院公共学科基础课程教学大纲汇编(2022年版).pdf
- 上海海洋大学:信息学院专业课程教学大纲汇编(2022年版).pdf
- 上海海洋大学:信息学院信息与计算科学专业2018版课程教学大纲汇编.pdf
- 上海海洋大学:信息学院空间信息与数字技术专业2018版课程教学大纲汇编.pdf
- 上海海洋大学:信息学院软件工程专业2018版课程教学大纲汇编.pdf
- 上海海洋大学:信息学院计算机科学与技术专业2018版课程教学大纲汇编.pdf
- 上海海洋大学:信息学院2011年版课程教学大纲汇编(下册).pdf
- 上海海洋大学:信息学院2011年版课程教学大纲汇编(上册).pdf
- 吉林大学:《计算机网络基础》课程电子教案(PPT课件)第一章 概论(负责人:刘衍珩).ppt
- 吉林大学:《计算机网络基础》课程电子教案(PPT课件)第八章 网络互联.ppt
- 吉林大学:《计算机网络基础》课程电子教案(PPT课件)第七章 应用层.ppt
- 吉林大学:《计算机网络基础》课程电子教案(PPT课件)第六章 传输层.ppt
- 吉林大学:《计算机网络基础》课程电子教案(PPT课件)第五章 局域网.ppt
- 吉林大学:《计算机网络基础》课程电子教案(PPT课件)第四章 网络层.ppt
- 吉林大学:《计算机网络基础》课程电子教案(PPT课件)第三章 数据链路层.ppt
- 《超级计算》教学资源(参考资料)01 高性能并行计算机简介(PPTminimizer).ppt
- 《超级计算》教学资源(参考资料)Linux Kernel Internals.pdf
- 《超级计算》教学资源(参考资料)Linux Secure and Optimized Server.pdf
- 《超级计算》教学资源(参考资料)Linux环境下程序编译.ppt
- 《超级计算》教学资源(参考资料)高性能计算之并行编程技术——MPI并行程序设计.pdf
- 《电脑编程》教学参考书籍文献(C++编程书籍)Addison Wesley - Effcient C++ Programming Techniques.pdf
- 《电脑编程》教学参考书籍文献(C++编程书籍)设计模式 - 可利用面向对象软件的基础 Design Patterns - Elements of Reusable Object-Oriented Software.pdf
- 《电脑编程》教学参考书籍文献(JAVA)EJB Design Patterns Advanced Patterns, Processes, and Idioms(2002, Floyd Marinescu, Wiley).pdf
- 《电脑编程》教学参考书籍文献(JAVA)Introduction to Java Distributed Objects - Using RMI and CORBA.pdf
- 《电脑编程》教学参考书籍文献(JAVA)J2EE指南(共十七章).pdf
- 《电脑编程》教学参考书籍文献(Fortran)FORTRAN常用算法程序集(第二版,共十五章,编著:徐士良).pdf
- A-Duplex:Medium Access Control for Efficient Coexistence Between Full-Duplex and Half-Duplex Communications.pdf
- 沈阳航空航天大学:自动化学院《计算机控制技术》课程教学大纲.pdf
- 《数据库管理及应用》课程电子教案(PPT课件)0.0 Development History for Database.ppt
- 《数据库管理及应用》课程电子教案(PPT课件)1.01 Database 数据库.ppt
- 《数据库管理及应用》课程电子教案(PPT课件)1.02 Data Description of real world 真实世界的数据描述.ppt
- 《数据库管理及应用》课程电子教案(PPT课件)2.01 data Model of Database 数据库的数据模型.ppt
- 《数据库管理及应用》课程电子教案(PPT课件)2.02 Relation Calculus 关系运算.ppt
- 《数据库管理及应用》课程电子教案(PPT课件)2.03 Tuple&Domain Relation Calculus 元组和域关系演算.ppt
- 《数据库管理及应用》课程电子教案(PPT课件)3.01 Data Manipulation languages 数据操纵语言.ppt