当前位置:高等教育资讯网  >  中国高校课件下载中心  >  大学文库  >  浏览文档

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

资源类别:文库,文档格式:PPT,文档页数:43,文件大小:619.5KB,团购合买
• The shell of Linux • Bourne Shell Programming • find.and.regular.expression • text manipulation
点击下载完整版文档(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

点击下载完整版文档(PPT)VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
共43页,可试读15页,点击继续阅读 ↓↓
相关文档

关于我们|帮助中心|下载说明|相关软件|意见反馈|联系我们

Copyright © 2008-现在 cucdc.com 高等教育资讯网 版权所有