aix系统应用基础08shellbasics.ppt

上传人:sccc 文档编号:4767321 上传时间:2023-05-14 格式:PPT 页数:25 大小:309KB
返回 下载 相关 举报
aix系统应用基础08shellbasics.ppt_第1页
第1页 / 共25页
aix系统应用基础08shellbasics.ppt_第2页
第2页 / 共25页
aix系统应用基础08shellbasics.ppt_第3页
第3页 / 共25页
aix系统应用基础08shellbasics.ppt_第4页
第4页 / 共25页
aix系统应用基础08shellbasics.ppt_第5页
第5页 / 共25页
点击查看更多>>
资源描述

《aix系统应用基础08shellbasics.ppt》由会员分享,可在线阅读,更多相关《aix系统应用基础08shellbasics.ppt(25页珍藏版)》请在三一办公上搜索。

1、 Copyright IBM Corporation 2008,Unit 8Shell Basics,更侍蚜车钦舶就熏懦筏锤艳豺海蔷逆寞浴礁刊喊秆猴犁匝胜优曲担利肠珊aix系统应用基础08 shell basicsaix系统应用基础08 shell basics,Copyright IBM Corporation 2008,Unit Objectives,After completing this unit,you should be able to:Use wildcards to access files with similar namesUse redirection and pipe

2、s to control the input and output of processesUse line continuation to enter commands that span the command lineGroup commands in order to control their execution,崩实祁匣校硒笨康滦揣释椰汽铱讶驳霹馒凡法湍柜容造刹淖照日靡少炙僚aix系统应用基础08 shell basicsaix系统应用基础08 shell basics,Copyright IBM Corporation 2008,The Shell,Korn(ksh)or Bou

3、rne(bsh)or C(csh)User interface to AIXCommand interpreterEnables multiple tasksComprehensive programming language,衷开姨焙渐交埂镍钵诉晕稽荐罗抛椿诊缨轨直捣呼沽纪颁启侮猛荷嚣芭嚏aix系统应用基础08 shell basicsaix系统应用基础08 shell basics,Copyright IBM Corporation 2008,Metacharacters and Wildcards,Metacharacters are characters that the shell

4、interprets as having a special meaning.Examples:|;!*?$Wildcards are a subset of metacharacters that are used to search for and match file patterns.Examples:*?!-,榨角词烁囱倪蛊忘屈娠岸寞救许阿剁男直蚌矩苯瞎喉跪隧剑昔外懦册沈躬aix系统应用基础08 shell basicsaix系统应用基础08 shell basics,Copyright IBM Corporation 2008,/hometeam01 test1 test1.2 t

5、est1.3 myfile ne net new nest few,File Name Substitution(1 of 2),Wildcards:*?One character compare:$ls ne?net new$rm?e?few net newMultiple character compare:$cp n*/tmpne net new nest$qprt*wnew few$echo test1*test1 test1.2 test1.3,介舵琳肘趣袖鹿釉幅荡虱棕瞎伸亦织赤韵氏垃艳厘场够夹免停恋弦植园养aix系统应用基础08 shell basicsaix系统应用基础08 sh

6、ell basics,Copyright IBM Corporation 2008,Inclusive Lists:!-$ls nestwnet new$rm fghjdnetwfew net new$ls*1-5test1 test1.2 test1.3$qprt!tn*myfile few$cat?!y*2-5test1.2 test1.3,/hometeam01 test1 test1.2 test1.3 myfile ne net new nest few,File Name Substitution(2 of 2),齿申脚逾摹荆坦砰奥牧犯昆横坍哦膏形墒咎睁褥锋是难撞墩饰惋关呸淑都ai

7、x系统应用基础08 shell basicsaix系统应用基础08 shell basics,Copyright IBM Corporation 2008,standard in(0),standard error(2),standard out(1),cmd,The Standard Files,嗅付瑟空镭团册筐反独草翱碗搁栈贵婶正坊芋腺掸温斡膏峦秋腐鼠蔑榆犬aix系统应用基础08 shell basicsaix系统应用基础08 shell basics,Copyright IBM Corporation 2008,Standard in:1Standard error:22,File De

8、scriptors,Three descriptors are assigned by the shell when the program starts:,抉尾纹术蓟盘涅颇编乒虚混书季膝装座条茸享敝到荤叔吉械裁阶弃狞忱春aix系统应用基础08 shell basicsaix系统应用基础08 shell basics,Copyright IBM Corporation 2008,Input Redirection,Default standard input$mail team01Subject:LetterThis is a letter.Cc:$Redirect input from a

9、file:$mail team01 letter$,幻醚高嗡渔狗三啮醋扳硅弛虱睫岔歪买镑寒妮铰嚼氮肿临倚角庇候药将咖aix系统应用基础08 shell basicsaix系统应用基础08 shell basics,Copyright IBM Corporation 2008,Output Redirection,Default standard output:$lsfile1file2 file3Redirect output from a file:$ls ls.out$Redirecting and appending output to a file:$who whos.there$,坝

10、午渍牲猜爵黎迷疯柑侄茎淹势蝗嫉趾劫酱邱煮咙伯葱拷灾曾搓峰孕崭宿aix系统应用基础08 shell basicsaix系统应用基础08 shell basics,Copyright IBM Corporation 2008,Creating a File with cat,While normally used to list the contents of files,using cat with redirection can be used to create a file:$ls letter acctfile file1$cat file1 This is a test file.Th

11、e file has 2 lines.$Using redirection:$cat newfileThis is line 1 of the file.This is the 2nd line.And the last.$lsletter acctfile file1 newfile,碑辕留果堵魔夏邹井包逆激对蕾哗这逢睁耕残躇涝沥阻偷惦逛稻洋尊论失aix系统应用基础08 shell basicsaix系统应用基础08 shell basics,Copyright IBM Corporation 2008,Activity:Review Shell Basics,Which files are

12、 listed when the following commands are executed?$ls/home/team01/*.?$ls/tmp/a-zA-Z*.0-9True or False:The command ls*lists all files in a directory.Write down the file descriptors for the following command:$wc-l/tmp/linesStandard input:Standard output:Standard error:You want to append file testfile1

13、to file report99.Which command is correct?cat report99 report99cat testfile1 report99cat testfile1 report99,领英篓虑蚕又奸拳期舀窄峦邵沉直彼毫篡洱睫玩嚏兄爪厚金呜醇角撅赚刘aix系统应用基础08 shell basicsaix系统应用基础08 shell basics,Copyright IBM Corporation 2008,Error Redirection,Default standard error:$cat filea filebThis is output from fil

14、ea.cat:cannot open filebRedirecting error output to a file:2(To append:2)$cat filea fileb 2 errfileThis is output from filea$cat errfilecat:cannot open fileb$cat filea fileb 2/dev/nullThis is output from filea,率键数子旱酱棱失桑搏巡肃割绘妊售柬荒孩阑娱怯瑚逸渭更部埠哇晤谭骤aix系统应用基础08 shell basicsaix系统应用基础08 shell basics,Copyright

15、 IBM Corporation 2008,Combined Redirection,Combined redirects:$command outfile 2 errfile appendfile 2 errfile outfile 2&1 CAUTION:This is NOT the same as above$command 2&1 outfile,其在阑雄汝功劝澜周准监讫停奢鹤禽蓄衷肮固米竞场首甘咬馆留调遗石兢aix系统应用基础08 shell basicsaix系统应用基础08 shell basics,Copyright IBM Corporation 2008,Pipes,A

16、sequence of one or more commands separated by a vertical bar|is called a pipe.The standard output of each command becomes the standard input of the next command.$who|wc-l 4This is the same as:$who tempfile$wc-l tempfile 4tempfile$rm tempfile,缸宏敷烩恳绣技渔茎另萄腊咯咯狂欣缚惭误靠栋输唁岂杯摆淘坚珐廓贸荚aix系统应用基础08 shell basicsai

17、x系统应用基础08 shell basics,Copyright IBM Corporation 2008,Long listing of all files:-rwxr-xr-x.file1drwxr-xr-.dir1-rwxr-r-.file2,Find all lines that begin with a d:drwxr-xr-.dir1,Count all lines(directories),Filters,A filter is a command that reads from standard in,transforms the input in some way,and w

18、rites to standard out.Example:ls-l|grep d|wc-l,涛摹姑滋色试厌竭庞补汛揉澳竭陆邀噎傲刚蛇涤仲娱蚁捂迄单萄绎嘴本傲aix系统应用基础08 shell basicsaix系统应用基础08 shell basics,Copyright IBM Corporation 2008,cowfoxox,/tmp/ls.save,3,cowfoxox,tee,ls,wc-l,Split Outputs,The tee command reads standard input and sends the data to both standard output an

19、d a file.ls|tee/tmp/ls.save|wc-l,衡算塔曼耘醇梗戏棚藻亡徐老寐崎娠炮讲伯需毁扮丈猴茶匠阑嚷郁徊莫喇aix系统应用基础08 shell basicsaix系统应用基础08 shell basics,Copyright IBM Corporation 2008,Command Grouping,Multiple commands can be entered on the same line,separated by a semi-colon;:$ls-R outfile;exitis equivalent to entering:$ls-R outfile$exi

20、t,突诬速杜隘颅缨引管茧潦粮作疾衍贡敷稗受邓腮陡形马熬煮羡私已慑积排aix系统应用基础08 shell basicsaix系统应用基础08 shell basics,Copyright IBM Corporation 2008,Line Continuation,The backslash()followed by a new line character can be used to continue a command on a separate line.A secondary prompt character is issued by the shell to indicate lin

21、e continuation.$cat/home/mydir/mysubdir/mydata/home/yourdir/yoursubdir/yourdata,曰铡驳假民沸罕列孟兑寺恐封席灼钝筷接磐挽奥岿啦贬钞闺孝淘阅忻蜡权aix系统应用基础08 shell basicsaix系统应用基础08 shell basics,Copyright IBM Corporation 2008,Checkpoint(1 of 2),What will the following command match?$ls?!a-z*0-9t For questions 2-4,indicate where the

22、standard input,standard output and standard error will go.$cat file1standard input(0):standard output(1):standard error(2):$mail tim letter standard input(0):standard output(1):standard error(2):,酥聪阳郑温目兹叠诗筹访心搽莎逝筐徒柜吃巡烦碧门铺鬼私酬涌五坤红久aix系统应用基础08 shell basicsaix系统应用基础08 shell basics,Copyright IBM Corporati

23、on 2008,Checkpoint Solutions(1 of 2),What will the following command match?$ls?!a-z*0-9tThis will list all the files that match the following criteria:the first three characters can be anythingthe fourth character must not be from the range a to zzero or more characters can followthe second-last cha

24、racter must be from the range 0 to 9the last character must be a t.For questions 2-4,indicate where the standard input,standard output and standard error will go.$cat file1standard input(0):keyboardstandard output(1):screenstandard error(2):screen$mail tim letter standard input(0):letterstandard out

25、put(1):screenstandard error(2):screen,粥沁芳袁呼漱嚼俞副燥栓晰厉沉奠漳堰捻霄葫又背吊浊焰雪佑梭暂够钢咨aix系统应用基础08 shell basicsaix系统应用基础08 shell basics,Copyright IBM Corporation 2008,Checkpoint(2 of 2),$cat.profile newprofile 21standard input(0):standard output(1):standard error(2):For questions 5,6,and 7,create command lines to di

26、splay the content of filea using cat and then perform the following:Place the output of the command in fileb and the errors in filec.Place the output of the command in fileb and associate any errors with the output in fileb.Place the output in fileb and discard any error messages.(Do not display or

27、store error messages.),只哆薛泳札斋敝幸蛰呐纂眉棕辕数涂曝桂屠汝蜒孵戎崖袖秸糙卢象蚀跺慎aix系统应用基础08 shell basicsaix系统应用基础08 shell basics,Copyright IBM Corporation 2008,Checkpoint Solutions(2 of 2),$cat.profile newprofile 21standard input(0):keyboardstandard output(1):newprofilestandard error(2):a file named 1For questions 5,6,and 7

28、,create command lines to display the content of filea using cat and then perform the following:Place the output of the command in fileb and the errors in filec.$cat filea fileb 2 filecPlace the output of the command in fileb and associate any errors with the output in fileb.$cat filea fileb 2&1Place

29、 the output in fileb and discard any error messages.(Do not display or store error messages.)$cat filea fileb 2/dev/null,冠潘近腺变盘守巳显靳杀蝴传柴势痊夜漱蹦榜甄穆病鲁犯磊裤户街降曾蛰aix系统应用基础08 shell basicsaix系统应用基础08 shell basics,Copyright IBM Corporation 2008,Exercise:Shell Basics,橙桥这壳盼棒述营沈似住桶自伤膘政畜狠括何尧橱伺朗史皮河狮松缆缠句aix系统应用基础08 s

30、hell basicsaix系统应用基础08 shell basics,Copyright IBM Corporation 2008,Unit Summary,Wildcards,*and?,provide a convenient way for specifying multiple files or directory names.The wildcard notation is like using the?but it allows you to choose specific characters to be matched.Three files automatically op

31、ened for redirection are standard in,standard out,and standard error.I/O redirection alters the default input source or output destination of a command.A pipe passes the output of one command directly to the input of another command.A filter takes input from standard in,transforms it,and sends the output to standard out.tee takes input and routes it to two places,standard out and a file.,泞酬筛苏炔披皂仑洞想滚秃副贮缩柳擅苦架先拧璃扳遏朱佛蹲蜜豁铺讳鱼aix系统应用基础08 shell basicsaix系统应用基础08 shell basics,

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 建筑/施工/环境 > 农业报告


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号