Appendix A Shell Metacharacters

> Output redirection >> Output append < Input redirection << Input from a here document I Pipe symbol && 'And if' symbol (a && b: run a and if successful run b) II 'Or if' symbol (a II b: run a and if unsucessful run b) .. Case delimiter " separator ' ' Command substitution ( ) Command grouping and running of commands in a sub-shell * Match any character ? Match any single character [ .. ] Match any of the enclosed characters \ Quote next character " " Quote the enclosed characters except for $, ", ', \ ' ' Quote the enclosed character except for ' $0 Name of invoking shell script $1 , .. $9 Arguments to shell script $name Value of variable name ${name} Substitution of variable name

187 Appendix B Comparison of Bourne Shell and C Shell Constructs

Bourne shell C shell if condition if (condition) then then statement (s) statements elif condition else if (condition) then then statements statements else else statements statements fi end if times for name [in word-list] foreach name [word-list] do statement (s) statement (s) end done case word in switch (word) option ) crnds;; case option: crnds breaksw * crnds;; default: cmds breaksw esac endsw [ ] exit [ (expr)] export setenv trap 'crnds' signals onintr label • filename source filename continue continue while condition while (condition) do statements statements end done read readonly break [n] break [break]

189 Appendix C ASCII Tables

The two tables below show the octal and hexadecimal equivalents of each ASCII character.

Table C.l. ASCII character conversion chart (octal) 000 nul 001 sch 002 stx 003 etx 004 ect 005 enq 006 ack 007 bel 010 bs 011 ht 012 n1 013 vt 014 np 015 cr 016 so 017 si 020 dle 021 del 022 dc2 023 dc3 024 dc4 025 nak 026 syn 027 etb 030 can 031 ern 032 sub 033 esc 034 fs 035 gs 036 rs 037 us 040 sp 041 042 II 043 il 044 $ 045 % 046 & 047 I 050 ( 051 ) 052 * 053 + 054 055 - 056 057 I 060 0 061 1 062 2 063 3 064 4 065 5 066 6 067 7 070 8 071 9 072 073 i 074 < 075 = 076 > 077 ? 100 @ 101 A 102 B 103 c 104 D 105 E 106 F 107 G 110H 111 I 112 J 113 K 1141 115M 116N 117 0 120 p 121 Q 122 R 123 s 124 T 125 u 126 v 127 w 130 X 131 y 132 z 133 [ 134 \ 135 l 136 A 137 140 ' 141 a 142 b 143 c 144 d 145 e 146 f 147 g 150 h 151 i 152 j 153 k 154 1 155 rn 156 n 157 0 160 p 161 q 162 r 163 s 164 t 165 u 166 v 167 w 170 X 171 y 172 z 173 { 174 I 175 } 176 ~ 177 del

Table C.2. ASCII character conversion chart (hexadecimal) 00 nul 01 soh 02 stx 03 etx 04 eot 05 enq 06 ack 07 bel 08 bs 09 ht Oa n1 Ob vt Oc np cr Oe so Of si 10 dle 11 del 12 dc2 13 dc3 14 dc4 15 nak 16 syn 17 etb 18 can 19 ern 1a sub lb esc lc fs ld gs 1e rs lf us 20 sp 21 22 II 23 il 24 $ 25 % 26 & 27 I 28 ( 29 ) 2a * 2b + 2c 1 2d- 2e . 2f I 30 0 31 1 32 2 33 3 34 4 35 5 36 6 37 7 38 8 39 9 3a : 3b i 3c < 3d = 3e > 3f ? 40 @ 41 A 42 B 43 c 44 D 45 E 46 F 47 G 48 H 49 I 4a J 4b K 4c L 4d M 4e N 4f 0 50 p 51 Q 52 R 53 s 54 T 55 u 56 v 57 w 58 X 59 y Sa Z Sb [ Sc \ Sd l Se A Sf 60 ' 61 a 62 b 63 c 64 d 65 e 66 f 67 g 68 h 69 i 6a j- 6b k 6c 1 6d rn 6e n 6f 0 70 p 71q 72 r 73 s 74 t 75 u 76 v 77 w 78 X 79 y 7a z 7b { 7c I 7d } 7e ~ 7f del

191 Index

12 /dev/mem 178, 180 cc 21,37, 79,80,81,88 /dev/null 24 10 /etc/checklist 174 cdc 141 /etc/clri 176 16 /etc/gettydefs 161, 177 close 106 /etc/group 166 54 /etc/init 153 commands 21 /etc/inittab 161, 177, 153 grouping 21 /etc/mknod 176 substitution 28 /etc/passwd 153, 166 conditional compilation 81 /etc/rc 161 13 /etc/utmp 161 cpio 163 /lost+found 174 146 /unix 168, 178 cu 158 55 adding users 166 admin 136 date 21 alarm 101 165 85 deleting users 168 archiving 163 169, 170 145 disk utilisation 169 atof 94 169, 170 atoi 94 atol 94 28 47,36 editor 63 editor 59 background commands 21 elif 32 backing up 163 env 41 boot block 171 environ 43 environment 42, 45 C language 42, 79, 89 execl 96,97 calendar 144 execle 43 case 33

193 194 The UNIX Workshop

execlp 96 kernel 4 execv 96 31, 99, 162 exit 95 export 41 ldgetname 179 expr 29,37 ldopen 179 ldtbindex 179 files 8 ldtbread 179 modes 17 ldtbseek 179 system 18, 171 libraries 85 file system repair 17 4 In 14 filters 5, 25 logging in 6 14 logout 7 flag arguments 22 longjmp 103 for 34 lp 13 fork 97 lpstat 13 fsck 174 Is 12,25 function calls 39 mail 142 getnev 43 127 53 man 7 mem 178 here document 31 memory management 4 menu development 38 if 32, 36 143 1-list 172 message queues 110 impure t.s. programs 84 metacharacters 23, 24 init 161, 171, 177 11 inode 172 mkfs 173 ipcrm 110 mm 71 109 mount 19 isalnum 89 msgctl 112 isalpha 89 msgget 111 isascii 89 msgrcv 112 iscntrl 89 msgsnd 112 isdigit 89 13 isgraph 89 ISL area 173 named pipes 109 islower 89 news 145 isprint 89 nroff 66 ispunct 89 isspace 89 object file 79 isupper 89 od 57 isxdigit 89 optimisation 85 Index 195 paging 4 shmdt 116 password 6 shmget 116 56 signals 29, 99 pause 101 29 pclose 105 57, 170 pg 12 special characters 6 pipe 105 special files 18 pipelines 25 54 pipes 4, 8, 10 sprintf 93 popen 105 sscanf 92 pr 13 sticky bit 17 process 4 strcat 92 profiling 86, 87 strcmp 90 prs 140 strcpy 91 178 90 pure t.s. progrms 84 85 10 stripping 85 strlen 92 read 29,35 strncat 92 redirection 23 strncmp 91 11 strncpy 91 rmdel 141 suid 16 11 super block 171 swap area 171, 173 sact 140 swap space 17 sees 135 swapping 4 sccsdiff 141 sync 162, 173 semaphores 117 system 95 semctl 118 semget 118 tar 164 semop 118 29, 32, 33 set 42 tolower 90 setjmp 103 toupper 90 sgid 16 31,55 shared memory 115 trap 30, 35 shell 5,23 commands 21, 28 17 script 6 umount 19 variables 26 unget 141 shmat 116 unnamed pipes 104 shmctl 116 unset 42 196 The UNIX Workshop until 34 29,98 users 15 wall 29, 144 uucp 149 we 53 uulog 157 what 139 uupick 158 while 34, 35 uustat 157 23 143 editor 59