Intel XENIX 286 Programmers Guide (86) - Tenox.tc
Intel XENIX 286 Programmers Guide (86) - Tenox.tc Intel XENIX 286 Programmers Guide (86) - Tenox.tc
XENIX Programming Programming Commands csh (continued) Command and File Name Substitution Command and file name substitution are applied selectively to the arguments of built-in commands. This means that portions of expressions that are not evaluated are not subjected to these expansions. For commands that are not internal to the shell, the command name is substituted separately from the argu ment list. This occurs very late, after input-output redirection is performed, and in a child of the main shell. Command Substitution. Command substitution is indicated by a command enclosed in back quotation marks (). The output from such a command is normally broken into separate words at blanks, tabs and newlines, with null words being discarded, this text then replacing the original string. Within double quotation marks, only newlines force new words; blanks and tabs are preserved. In any case, the single final newline does not force a new word. Note that it is thus possible for a command substitution to yield only part of a word, even if the command outputs a complete line. File Name Substitution. If a word contains any of the characters *, ? , [, or { or begins with the character -, then that word is a candidate for file name substitution, also known as globbing. This word is then regarded as a pattern and replaced with an alphabetically sorted list of file names that match the pattern. In a list of words specifying file name substitution it is an error for no pattern to match an existing file name, but it is not required for each pattern to match. Only the metacharacters *, ? , and [ imply pattern matching, the characters - and { being more akin to abbreviations. In matching file names, the character dot (.) at the beginning of a file name or immediately following a slash {/), as well as the character I itself must be matched explicitly. The character asterisk (*) matches any string of characters, including the null string. The character question mark (?) matches any single character. The sequence [ • •• ] matches any one of the characters enclosed. Within [ ••• ], a pair of characters separated by dash (-) matches any character lexically between the two (inclusive). The character tilde (-) at the beginning of a file name is used to refer to home directories. Standing alone, it expands to the invoker's home directory as reflected in the value of the variable home. When followed by a name consisting of letters, digits and dash characters (-), the shell searches for a user with that name and substitutes his or her home directory; thus -ken might expand to /usr/ken and -ken/chmach to /usr/ken/chmach. If the character - is followed by a character other than a letter or slash {/) or if it appears somewhere besides the beginning of a word, it is left unchanged. The metanotation a{b,c,d}e is a shorthand for abe ace ade. Left-to-right order is preserved, with results of matches being sorted separately at a low level to preserve this order. This construct may be nested. Thus, -source/sl/{oldls,ls}.c expands to /usr/source/sl/oldls.c /usr/source/sl/ls.c, whether or not these files exist and without any chance of error if the home directory for source is /usr/source. Similarly, •• /{memo,*box} might expand to •• /memo •• /box •• /mbox. (Note that memo was not sorted with the results of matching *box.) As a special case {, } and D are passed unchanged. 8-41
Programming Commands XENIX Programming csh (continued) Input/Output The standard input and standard output of a command may be redirected with the following syntax: &name >&!name The file name is used as standard output. If the file does not exist, then it is created; if the file exists, it is truncated, and its previous contents are lost. >>name >>&name >>!name >>&!name B-42 If the variable noclobber is set, then the file must not already exist, or it must be a character special file (for example, a terminal or /dev/null); otherwise, an error results. This provision helps prevent accidental destruction of files. In this case the ! forms can be used to suppress a check. The forms involving & route the diagnostic output into the specified file as well as the standard output. name is expanded in the same way as < input file names are. Uses the file name as standard output like > but places output at the end of the file. If the variable noclobber is set, then it is an error for the file not to exist unless one of the ! forms is given. Otherwise similar to >.
- Page 255 and 256: C Language Portability XENIX Progra
- Page 257 and 258: C Language Portability XENIX Progra
- Page 259 and 260: C Language Portability XENIX Progra
- Page 261 and 262: C Language Portability XENIX Progra
- Page 263 and 264: C Language Portability XENIX Progra
- Page 266 and 267: APPENDIX B PROG RAMMING COMMANDS Th
- Page 268 and 269: XENIX Programming ad b (continued)
- Page 270 and 271: XENIX Programming Programming Comma
- Page 272 and 273: XENIX Programming Programming Comma
- Page 274 and 275: XENIX Programming Programming Comma
- Page 276 and 277: XENIX Programming Programming Comma
- Page 278 and 279: XENIX Programming Programming Comma
- Page 280 and 281: XENIX Programming Programming Comma
- Page 282 and 283: XENIX Programming Programming Comma
- Page 284 and 285: XENIX Programming as (continued) Fi
- Page 286 and 287: XENIX Programming Programming Comma
- Page 288 and 289: XENIX Programming Programming Comma
- Page 290 and 291: XENIX Programming Programm ing Comm
- Page 292 and 293: XENIX Programming Programming Comma
- Page 294 and 295: XENIX Programming Programming Comma
- Page 296 and 297: XENIX Programming Programm ing Comm
- Page 298 and 299: XENIX Programming Programming Comma
- Page 300 and 301: XENIX Programming Programming Comma
- Page 302 and 303: XENIX Programming Programming Comma
- Page 304 and 305: XENIX Programming Programming Comma
- Page 308 and 309: XENIX Programming Programming Comma
- Page 310 and 311: XENIX Programming Programming Comma
- Page 312 and 313: XENIX Programming Programming Comma
- Page 314 and 315: XENIX Programm ing Programming Comm
- Page 316 and 317: XENIX Programming Programming Comma
- Page 318 and 319: XENIX Programming Programming Comma
- Page 320 and 321: XENIX Programming Programming Comma
- Page 322 and 323: XENIX Programming Programming Comma
- Page 324 and 325: XENIX Programming Programming Comma
- Page 326 and 327: XENIX Programming Programming Comma
- Page 328 and 329: XENIX Programming Programming Comma
- Page 330 and 331: XENIX Programming Programming Comma
- Page 332 and 333: XENIX Programming Programming Comma
- Page 334 and 335: XENIX Programming Programming Comma
- Page 336 and 337: XENIX Programming Programming Comma
- Page 338 and 339: XENIX Programming Programming Comma
- Page 340 and 341: XENIX Programming Programming Comma
- Page 342 and 343: XENIX Programming Programming Comma
- Page 344 and 345: XENIX Programming lex (continued) E
- Page 346 and 347: XENIX Programming Programming Comma
- Page 348 and 349: XENIX Programming Programming Comma
- Page 350 and 351: XENIX Programming Programming Comma
- Page 352 and 353: XENIX Programming Programming Comma
- Page 354 and 355: XENIX Programming Programming Comma
<strong>XENIX</strong> Programming Programming Commands<br />
csh (continued)<br />
Command and File Name Substitution<br />
Command and file name substitution are applied selectively to the arguments of built-in<br />
commands. This means that portions of expressions that are not evaluated are not<br />
subjected to these expansions. For commands that are not internal to the shell, the<br />
command name is substituted separately from the argu ment list. This occurs very late,<br />
after input-output redirection is performed, and in a child of the main shell.<br />
Command Substitution. Command substitution is indicated by a command enclosed in<br />
back quotation marks (). The output from such a command is normally broken into<br />
separate words at blanks, tabs and newlines, with null words being discarded, this text<br />
then replacing the original string. Within double quotation marks, only newlines force<br />
new words; blanks and tabs are preserved.<br />
In any case, the single final newline does not force a new word. Note that it is thus<br />
possible for a command substitution to yield only part of a word, even if the command<br />
outputs a complete line.<br />
File Name Substitution. If a word contains any of the characters *, ? , [, or { or begins<br />
with the character -, then that word is a candidate for file name substitution, also known<br />
as globbing. This word is then regarded as a pattern and replaced with an alphabetically<br />
sorted list of file names that ma<strong>tc</strong>h the pattern. In a list of words specifying file name<br />
substitution it is an error for no pattern to ma<strong>tc</strong>h an existing file name, but it is not<br />
required for each pattern to ma<strong>tc</strong>h. Only the metacharacters *, ? , and [ imply pattern<br />
ma<strong>tc</strong>hing, the characters - and { being more akin to abbreviations.<br />
In ma<strong>tc</strong>hing file names, the character dot (.) at the beginning of a file name or<br />
immediately following a slash {/), as well as the character I itself must be ma<strong>tc</strong>hed<br />
explicitly. The character asterisk (*) ma<strong>tc</strong>hes any string of characters, including the<br />
null string. The character question mark (?) ma<strong>tc</strong>hes any single character. The<br />
sequence [ • •• ] ma<strong>tc</strong>hes any one of the characters enclosed. Within [ ••• ], a pair of<br />
characters separated by dash (-) ma<strong>tc</strong>hes any character lexically between the two<br />
(inclusive).<br />
The character tilde (-) at the beginning of a file name is used to refer to home<br />
directories. Standing alone, it expands to the invoker's home directory as reflected in<br />
the value of the variable home. When followed by a name consisting of letters, digits<br />
and dash characters (-), the shell searches for a user with that name and substitutes his<br />
or her home directory; thus -ken might expand to /usr/ken and -ken/chmach to<br />
/usr/ken/chmach. If the character - is followed by a character other than a letter or<br />
slash {/) or if it appears somewhere besides the beginning of a word, it is left unchanged.<br />
The metanotation a{b,c,d}e is a shorthand for abe ace ade. Left-to-right order is<br />
preserved, with results of ma<strong>tc</strong>hes being sorted separately at a low level to preserve<br />
this order. This construct may be nested. Thus, -source/sl/{oldls,ls}.c expands to<br />
/usr/source/sl/oldls.c /usr/source/sl/ls.c, whether or not these files exist and without<br />
any chance of error if the home directory for source is /usr/source. Similarly,<br />
•• /{memo,*box} might expand to •• /memo •• /box •• /mbox. (Note that memo was not<br />
sorted with the results of ma<strong>tc</strong>hing *box.) As a special case {, } and D are passed<br />
unchanged.<br />
8-41