UNIX Shell编程.ppt
《UNIX Shell编程.ppt》由会员分享,可在线阅读,更多相关《UNIX Shell编程.ppt(70页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、 2010 Hewlett-Packard Development Company,L.P.The information contained herein is subject to change without notice UNIX Shell-Scripting BasicsAgendalWhat is a shell?A shell script?lIntroduction to bashlRunning CommandslApplied Shell ProgrammingWhat is a shell?%What is a shell?/bin/bashWhat is a shel
2、l?#!/bin/bashWhat is a shell?INPUTshellOUTPUTERRORWhat is a shell?lAny ProgramlBut there are a few popular shellsBourne Shellsl/bin/shl/bin/bash“Bourne-Again Shell”Steve BourneOther Common ShellslC Shell(/bin/csh)lTurbo C Shell(/bin/tcsh)lKorn Shell(/bin/ksh)An aside:What do I mean by/bin?lC Shell(/
3、bin/csh)lTurbo C Shell(/bin/tcsh)lKorn Shell(/bin/ksh)An aside:What do I mean by/bin?l/bin,/usr/bin,/usr/local/binl/sbin,/usr/sbin,/usr/local/sbinl/tmpl/devl/home/borwicjhWhat is a Shell Script?lA Text FilelWith InstructionslExecutableWhat is a Shell Script?%cat hello.sh%cat hello.shhello.sh MY_PROG
4、RAM /tmp/myfilelcat /tmp/myfilelcat 2/tmp/myerrlcat /tmp/myinputlcat /tmp/x 2&1INPUTenvOUTPUTERROR012What is a Shell Script?How To Run%cat hello.sh hello.sh hello.sh hello.sh test.sh _TEST_exit 3_TEST_%chmod+x test.sh%./test.sh%echo$?3Logic:test%test 1-lt 10%echo$?0%test 1=10%echo$?1Logic:testltestl
5、 1 lt 10 l “this string”=“this”l()(1 10)Logic:testl-f/etc/passwd l!f/etc/passwd l-f/etc/passwd a f/etc/shadow l-f/etc/passwd o f/etc/shadow An aside:$()for Math%echo$(1+2)3%echo$(2*3)6%echo$(1/3)0Logic:ifif somethingthen :#“elif”a contraction of“else if”:elif something-elsethen :elsethen :fiLogic:if
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- UNIX Shell编程 Shell 编程
限制150内