aix系统应用基础08shellbasics_第1页
aix系统应用基础08shellbasics_第2页
aix系统应用基础08shellbasics_第3页
aix系统应用基础08shellbasics_第4页
aix系统应用基础08shellbasics_第5页
已阅读5页,还剩20页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、 Copyright IBM Corporation 2008,Unit 8Shell Basics, Copyright IBM Corporation 2008,Unit Objectives,After completing this unit, you should be able to: Use wildcards to access files with similar names Use redirection and pipes to control the input and output of processes Use line continuation to enter

2、 commands that span the command line Group commands in order to control their execution, Copyright IBM Corporation 2008,The Shell,Korn (ksh) or Bourne (bsh) or C (csh) User interface to AIX Command interpreter Enables multiple tasks Comprehensive programming language, Copyright IBM Corporation 2008,

3、Metacharacters and Wildcards,Metacharacters are characters that the shell interprets as having a special meaning. Examples: | ; ! * ? $ Wildcards are a subset of metacharacters that are used to search for and match . Examples: * ? ! - , Copyright IBM Corporation 2008,/ home team01 test1 test1.2 test

4、1.3 myfile ne net new nest few,Substitution (1 of 2),Wildcards: *? One character compare: $ ls ne? net new $ rm ?e? few net new Multiple character compare: $ cp n* /tmp ne net new nest $ qprt *w new few $ echo test1* test1 test1.2 test1.3, Copyright IBM Corporation 2008,Inclusive Lists: ! - $ ls nes

5、tw net new $ rm fghjdnetw few net new $ ls *1-5 test1 test1.2 test1.3 $ qprt !tn* myfile few $ cat ?!y*2-5 test1.2 test1.3,/ home team01 test1 test1.2 test1.3 myfile ne net new nest few,Substitution (2 of 2), Copyright IBM Corporation 2008,standard in (0),standard error (2),standard out (1),cmd,The

6、Standard Files, Copyright IBM Corporation 2008,Standard in:1 Standard error:22,Three descriptors are assigned by the shell when the program starts:, Copyright IBM Corporation 2008,Input Redirection,Default standard input $ mail team01 Subject: Letter This is a letter. Cc: $ Redirect input from a fil

7、e: $ mail team01 letter $, Copyright IBM Corporation 2008,Output Redirection,Default standard output: $ ls file1file2 file3 Redirect output from a file: $ ls ls.out $ Redirecting and appending output to a file: $ who whos.there $, Copyright IBM Corporation 2008,Creating a cat,While normally used to

8、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. The 2 lines. $ Using redirection: $ cat newfile This is line 1 of the file. This is the 2nd line. And the last. $ ls letter acctfile file1 newfile, Copyrig

9、ht IBM Corporation 2008,Activity: Review Shell Basics,Which files are listed when the following commands are executed? $ ls /home/team01/*.? $ ls /tmp/a-zA-Z*.0-9 True or False: The command ls * lists all files in a directory. Write down the for the following command: $ wc -l /tmp/lines Standard inp

10、ut: Standard output: Standard error: You want to append file testfile1 to file report99. Which command is correct? cat report99 report99 cat testfile1 report99 cat testfile1 report99, Copyright IBM Corporation 2008,Error Redirection,Default standard error: $ cat filea fileb This is output from filea

11、. cat: cannot open fileb Redirecting error output to a file: 2 (To append: 2) $ cat filea fileb 2 errfile This is output from filea $ cat errfile cat: cannot open fileb $ cat filea fileb 2 /dev/null This is output from filea, Copyright IBM Corporation 2008,Combined Redirection,Combined redirects: $

12、command outfile 2 errfile appendfile 2 errfile outfile 2: $ ls -R outfile ; exit is equivalent to entering: $ ls -R outfile $ exit, 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 pro

13、mpt character is issued by the shell to indicate line continuation. $ cat /home/mydir/mysubdir/mydata /home/yourdir/yoursubdir/yourdata, 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 standard input, sta

14、ndard output and standard error will go. $ cat file1 standard input (0): standard output (1): standard error (2): $ mail tim letter standard input (0): standard output (1): standard error (2):, Copyright IBM Corporation 2008,Checkpoint Solutions (1 of 2),What will the following command match? $ ls ?

15、!a-z*0-9t This will list all the files that match the following criteria: the first three characters can be anything the fourth character must not be from the range a to z zero or more characters can follow the second-last character must be from the range 0 to 9 the last character must be a t. For q

16、uestions 2-4, indicate where the standard input, standard output and standard error will go. $ cat file1 standard input (0): keyboard standard output (1): screen standard error (2): screen $ mail tim letter standard input (0): letter standard output (1): screen standard error (2): screen, Copyright

17、IBM Corporation 2008,Checkpoint (2 of 2),$ cat .profile newprofile 21 standard input (0): standard output (1): standard error (2): For questions 5, 6, and 7, 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 th

18、e 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 store error messages.), Copyright IBM Corporation 2008,Checkpoint Solutions (2 of 2),$ cat .profile newprofile 2

19、1 standard input (0): keyboard standard output (1): newprofile standard error (2): a 1 For questions 5, 6, and 7, 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 filec

20、 Place the output of the command in fileb and associate any errors with the output in fileb. $ cat filea fileb 2&1 Place the output in fileb and discard any error messages. (Do not display or store error messages.) $ cat filea fileb 2 /dev/null, Copyright IBM Corporation 2008,Exercise: Shell Basics, Copyr

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论