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