Version 7.2 System i - IBM

System i Version 7.2

Programming Qshell

IBM

Note Before using this information and the product it supports, read the information in "Notices" on page 197.

This document may contain references to Licensed Internal Code. Licensed Internal Code is Machine Code and is licensed to you under the terms of the IBM License Agreement for Machine Code. ? Copyright International Business Machines Corporation 2008, 2013. US Government Users Restricted Rights ? Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.

Contents

Qshell................................................................................................................... 1

PDF file for Qshell........................................................................................................................................ 1 Tutorial......................................................................................................................................................... 2

Qshell command language features...................................................................................................... 2 Qshell utility features............................................................................................................................. 4 Putting it all together in a script............................................................................................................. 6 Command language..................................................................................................................................... 7 Quoting....................................................................................................................................................7 Parameters............................................................................................................................................. 7 Shell variables.........................................................................................................................................8 Word expansions.................................................................................................................................. 12

Tilde expansions............................................................................................................................. 12 Parameter expansions.................................................................................................................... 13 Command substitutions................................................................................................................. 15 Arithmetic expansions.................................................................................................................... 16 Field splitting.................................................................................................................................. 18 Patterns........................................................................................................................................... 18 Redirection........................................................................................................................................... 19 Simple commands................................................................................................................................20 Pipelines............................................................................................................................................... 21 Lists.......................................................................................................................................................21 Shell functions......................................................................................................................................22 Grouping commands.......................................................................................................................22 If command.....................................................................................................................................22 Conditional command.....................................................................................................................23 Case command............................................................................................................................... 23 Select command............................................................................................................................. 24 While command.............................................................................................................................. 24 Until command................................................................................................................................25 For command.................................................................................................................................. 25 Functions.........................................................................................................................................25 Using Qshell............................................................................................................................................... 26 Using a Qshell interactive session....................................................................................................... 26 Running Qshell commands from CL.....................................................................................................27 Running Qshell commands from PASE................................................................................................ 28 Customizing the Qshell environment...................................................................................................28 National language support (NLS) considerations................................................................................29 Performance considerations................................................................................................................ 34 Developing your own utilities...............................................................................................................34 Editing files with Qshell Interpreter.....................................................................................................35 Differences with other interpreters..................................................................................................... 35 Utilities....................................................................................................................................................... 36 Define aliases....................................................................................................................................... 41 alias................................................................................................................................................. 41 unalias............................................................................................................................................. 42 Run commands.....................................................................................................................................42 builtin.............................................................................................................................................. 42 command........................................................................................................................................ 43 dot................................................................................................................................................... 44 env................................................................................................................................................... 44 eval.................................................................................................................................................. 45

iii

exec................................................................................................................................................. 45 exit...................................................................................................................................................46 help..................................................................................................................................................47 nohup.............................................................................................................................................. 47 qsh................................................................................................................................................... 48 rexec................................................................................................................................................49 rexx..................................................................................................................................................50 source..............................................................................................................................................51 system............................................................................................................................................. 51 type..................................................................................................................................................53 whence............................................................................................................................................ 53 xargs................................................................................................................................................ 54 Manage data......................................................................................................................................... 55 cmp..................................................................................................................................................55 cut....................................................................................................................................................56 egrep............................................................................................................................................... 57 fgrep................................................................................................................................................ 57 grep................................................................................................................................................. 58 iconv................................................................................................................................................ 60 sed................................................................................................................................................... 61 sort.................................................................................................................................................. 65 split..................................................................................................................................................67 tr...................................................................................................................................................... 68 uniq..................................................................................................................................................70 wc.................................................................................................................................................... 71 Working with DB2.................................................................................................................................72 Qshell db2 utility.............................................................................................................................72 Perl utility........................................................................................................................................ 73 Working with files and directories....................................................................................................... 73 attr................................................................................................................................................... 74 basename........................................................................................................................................78 cat....................................................................................................................................................79 catsplf..............................................................................................................................................80 cd..................................................................................................................................................... 81 chgrp............................................................................................................................................... 81 chmod............................................................................................................................................. 83 chown.............................................................................................................................................. 86 compress.........................................................................................................................................87 cp..................................................................................................................................................... 88 dirname........................................................................................................................................... 90 file....................................................................................................................................................90 find...................................................................................................................................................91 gencat..............................................................................................................................................94 getconf............................................................................................................................................ 95 head.................................................................................................................................................97 ln......................................................................................................................................................97 ls...................................................................................................................................................... 98 mkdir............................................................................................................................................. 101 mkfifo............................................................................................................................................ 102 mv..................................................................................................................................................103 od.................................................................................................................................................. 103 pax.................................................................................................................................................105 pr................................................................................................................................................... 112 pwd................................................................................................................................................114 pwdx..............................................................................................................................................115 Rfile............................................................................................................................................... 115 rm.................................................................................................................................................. 117 rmdir..............................................................................................................................................118

iv

setccsid......................................................................................................................................... 118 tail................................................................................................................................................. 119 tar.................................................................................................................................................. 120 touch............................................................................................................................................. 121 umask............................................................................................................................................123 uncompress.................................................................................................................................. 124 zcat................................................................................................................................................ 124 Reading and writing input and output............................................................................................... 125 dspmsg..........................................................................................................................................125 echo...............................................................................................................................................126 print............................................................................................................................................... 126 printf..............................................................................................................................................127 read............................................................................................................................................... 128 Developing Java programs.................................................................................................................129 ajar................................................................................................................................................ 129 appletviewer................................................................................................................................. 132 extcheck........................................................................................................................................132 jar.................................................................................................................................................. 132 jarsigner........................................................................................................................................ 133 java................................................................................................................................................ 133 javac.............................................................................................................................................. 134 javadoc.......................................................................................................................................... 134 javah.............................................................................................................................................. 134 javakey.......................................................................................................................................... 135 javap.............................................................................................................................................. 135 keytool.......................................................................................................................................... 136 native2ascii................................................................................................................................... 136 policytool...................................................................................................................................... 136 rmic............................................................................................................................................... 136 rmid............................................................................................................................................... 136 rmiregistry.....................................................................................................................................136 serialver........................................................................................................................................ 137 tnameserv..................................................................................................................................... 137 Managing jobs.................................................................................................................................... 137 getjobid......................................................................................................................................... 137 hash...............................................................................................................................................138 jobs................................................................................................................................................139 kill..................................................................................................................................................139 liblist..............................................................................................................................................140 ps...................................................................................................................................................141 sleep..............................................................................................................................................144 trap................................................................................................................................................ 144 wait................................................................................................................................................145 Working with Kerberos credentials................................................................................................... 146 Working with the LDAP directory server............................................................................................146 Working with parameters and variables............................................................................................146 declare.......................................................................................................................................... 146 export............................................................................................................................................ 148 local...............................................................................................................................................149 printenv......................................................................................................................................... 149 readonly........................................................................................................................................ 150 set..................................................................................................................................................151 shift............................................................................................................................................... 153 typeset.......................................................................................................................................... 153 unset............................................................................................................................................. 153 Writing scripts.................................................................................................................................... 154 break............................................................................................................................................. 154 colon..............................................................................................................................................154

v

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download