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 csh: C Shell the C shell translates this to Is -s /usr/bill Note that the tilde (-) is a special C shell symbol that represents the user's home directory. Thus the alias command can be used to provide short names for commands, to provide default arguments, and to define new short commands in terms of other commands. You can also define aliases that contain multiple commands or pipelines, showing where the arguments to the original command are to be substituted using the facilities of the history mechanism. Thus the definition alias cd 'cd \!* ; Is ' specifies an Is command after each cd command. We enclosed the entire alias definition in single quotation marks (') to prevent most substitutions from occurring and to prevent the semicolon (;) from being recognized as a metacharacter. The exclamation mark (!) is escaped with a backslash (\) to prevent it from being interpreted when the alias command is typed in. The "\!*" here substitutes the entire argument list to the prealiasing cd com mand; no error is given if there are no arguments. The semicolon separating commands is used here to indicate that one command is to be done and then the next. Similarly, the following example defines a command that looks up its first argument in the password file. alias whois 'grep \! " /etc/passwd' The C shell reads the .cshrc file each time it starts up. If you place a large number of aliases there, C shells will tend to start slowly. You should try to limit the number of aliases you have to a reasonable number (10 or 15). Having too many aliases causes delays and makes the system seem sluggish when you execute commands from within an editor or other programs. Redirecting Input and Output In addition to the standard output, commands also have a standard error output that is normally directed to the terminal even when the standard output is redirected to a file or a pipe. It is occasionally useful to redirect the standard error output along with the standard output. For instance, if you want to redirect the output of a long-running command into a file and wish to have a record of any error message it produces, you can type command >& file The ">&" here tells the C shell to route both the standard error output and the standard output into file. Similarly, you can give a command of the form command I& lpr to route both standard output and standard error output through the pipe to the line printer. 8-7
csh: C Shell XENIX Programming The form command > &! file is used when noclobber is set and file already exists. Finally, use the form command > > file to append output to the end of an existing file. If noclobber is set, then an error results if file does not exist, otherwise the C shell creates file. The form command > > ! file appends to a file even if it does not exist and noclobber is set. Creating Background and Foreground Jobs When one or more commands are typed together as a pipeline or as a sequence of commands separated by semicolons, a single job is created by the C shell consisting of these commands together as a unit. Single commands without pipes or semicolons create the simplest jobs. Usually, every line typed to the C shell creates a job. Each of the following lines creates a job: sort < data Is -s I sort -n I head -5 mail harold If the ampersand metacharacter (&) is typed at the end of a command pipeline or sequence, then the job is started as a background job. This means that the C shell does not wait for the job to finish, but immediately prompts for another command. The job runs in the background at the same time that normal jobs, called foreground jobs, continue to be read and executed by the C shell. Thus du > usage & runs the du program, which reports on the disk usage of your working directory, directs the output into the file usage, and returns immediately with a prompt for the next command without waiting for du to finish. The du program continues executing in the background until it finishes, even though you can type and execute more commands in the mean time. Background jobs are unaffected by any signals from the keyboard such as the INTERRUPT or QUIT signals. The kill command terminates a background job immediately. Normally, this is done by specifying the process number of the job you want killed. Process numbers can be found with the ps command. 8-8
- Page 112 and 113: XENIX Programming adb: Program Debu
- Page 114 and 115: XENIX Programming adb: Program Debu
- Page 116 and 117: XENIX Programming int fcnt,gcnt,hcn
- Page 118 and 119: XENIX Programming adb: Program Debu
- Page 120 and 121: XENIX Programming adb: Program Debu
- Page 122 and 123: XENIX Programming adb: Program Debu
- Page 124 and 125: XENIX Programming adb: Program Debu
- Page 126 and 127: XENIX Programming adb: Program Debu
- Page 128: XENIX Programming adb: Program Debu
- Page 131 and 132: as: A sse m bier XENIX Programming
- Page 133 and 134: as: Assembler XENIX Programming The
- Page 135 and 136: as: Assembler XENIX Programming Key
- Page 137 and 138: as: Assembler The combination rules
- Page 139 and 140: as: Assembler XENIX Programming Ins
- Page 141 and 142: as: Assembler Initial Value Directi
- Page 143 and 144: as: Assembler XENIX Programming int
- Page 145 and 146: as: A sse m bier sub subb test test
- Page 147 and 148: as: Assembler XENIX Programming lnt
- Page 149 and 150: as: Assembler XENIX Programming lnt
- Page 151 and 152: as: Assembler XENIX Programming Imm
- Page 153 and 154: as: A sse m bier XENIX Programming
- Page 156 and 157: CHAPTER 8 csh : C SHEll The C shell
- Page 158 and 159: XENIX Programming csh: C Shell Some
- Page 160 and 161: XENIX Programm ing *w 32 * q % !c -
- Page 164 and 165: XENIX Programming csh: C Shell Usin
- Page 166 and 167: XENIX Programming csh: C Shell Usin
- Page 168 and 169: XENIX Programming csh: C Shell The
- Page 170 and 171: XENIX Programming csh: C Shell Note
- Page 172 and 173: XENIX Programming switch ( string c
- Page 174 and 175: XENIX Programming csh: C Shell Star
- Page 176 and 177: XENIX Programming csh: C Shell Spec
- Page 178 and 179: CHAPTER 9 lex : LEXICAL ANA LYZER G
- Page 180 and 181: XENIX Programming lex: Lexical Anal
- Page 182 and 183: XENIX Programming lex: Lexical Anal
- Page 184 and 185: XENIX Programming lex: Lexical Anal
- Page 186 and 187: XENIX Programming lex: Lexical Anal
- Page 188 and 189: XENIX Programming lex: Lexical Anal
- Page 190 and 191: XENIX Programming lex: Lexical Anal
- Page 192 and 193: XENIX Programm ing lex: Lexical Ana
- Page 194 and 195: XENIX Programming Specifying Source
- Page 196 and 197: XENIX Programming lex: Lexical Anal
- Page 198 and 199: XENIX Programming lex: Lexical Anal
- Page 200 and 201: XENIX Programming The definitions s
- Page 202 and 203: CHAPTER 10 yacc: COMPILER-COMPILER
- Page 204 and 205: XENIX Programming yacc: Compiler-Co
- Page 206 and 207: XENIX Programming yacc: Compiler-Co
- Page 208 and 209: XENIX Programming yacc: Compiler-Co
- Page 210 and 211: XENIX Programming yacc: Compiler-Co
csh: C Shell <strong>XENIX</strong> Programming<br />
The form<br />
command > &! file<br />
is used when noclobber is set and file already exists.<br />
Finally, use the form<br />
command > > file<br />
to append output to the end of an existing file. If noclobber is set, then an error results<br />
if file does not exist, otherwise the C shell creates file. The form<br />
command > > ! file<br />
appends to a file even if it does not exist and noclobber is set.<br />
Creating Background and Foreground Jobs<br />
When one or more commands are typed together as a pipeline or as a sequence of<br />
commands separated by semicolons, a single job is created by the C shell consisting of<br />
these commands together as a unit. Single commands without pipes or semicolons<br />
create the simplest jobs. Usually, every line typed to the C shell creates a job. Each of<br />
the following lines creates a job:<br />
sort < data<br />
Is -s I sort -n I head -5<br />
mail harold<br />
If the ampersand metacharacter (&) is typed at the end of a command pipeline or<br />
sequence, then the job is started as a background job. This means that the C shell does<br />
not wait for the job to finish, but immediately prompts for another command. The job<br />
runs in the background at the same time that normal jobs, called foreground jobs,<br />
continue to be read and executed by the C shell. Thus<br />
du > usage &<br />
runs the du program, which reports on the disk usage of your working directory, directs<br />
the output into the file usage, and returns immediately with a prompt for the next<br />
command without waiting for du to finish. The du program continues executing in the<br />
background until it finishes, even though you can type and execute more commands in<br />
the mean time. Background jobs are unaffected by any signals from the keyboard such<br />
as the INTERRUPT or QUIT signals.<br />
The kill command terminates a background job immediately. Normally, this is done by<br />
specifying the process number of the job you want killed. Process numbers can be found<br />
with the ps command.<br />
8-8