16.12.2012 Views

z/OS V1R9.0 UNIX System Services Command ... - Christian Grothoff

z/OS V1R9.0 UNIX System Services Command ... - Christian Grothoff

z/OS V1R9.0 UNIX System Services Command ... - Christian Grothoff

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

sh<br />

$(command)<br />

as in:<br />

ed $(grep –f –l function $(find . –name ’*.c’))<br />

This command uses find to search the current directory and its subdirectories to<br />

find all files, the names of which end in .c. It then uses grep –f to search each such<br />

file for those that contain the string function. Finally, it calls ed to edit each such<br />

file.<br />

There is a historical inconsistency in the backquoting syntax. A backslash (\) within<br />

a backquoted command is interpreted differently depending on its context.<br />

Backslashes are interpreted literally unless they precede a dollar sign ($), grave<br />

accent (`), or another backslash (\). In these cases, the leading backslash<br />

becomes an escape character to force the literal interpretation of the $, `, or \.<br />

Consequently, the command:<br />

echo ’\$x’<br />

issued at system level produces the output:<br />

\$x<br />

whereas the same command nested in a backquoted syntax:<br />

echo `echo ’\$x’`<br />

produces the output:<br />

$x<br />

We recommend the $(command) syntax for command substitutions.<br />

sh performs command substitutions as if a new copy of the shell is invoked to run<br />

the command. This affects the behavior of $− (standing for the list of options passed<br />

to the shell). If a command substitution contains $−, the expansion of $− does not<br />

include the –i option, since the command is being run by a non-interactive shell.<br />

File Descriptors and Redirection<br />

The shell sometimes refers to files using file descriptors. A file descriptor is a<br />

number in the range 0 to 9. It may have any number of digits. For example, the file<br />

descriptors 001 and 01 are identical to file descriptor 1. Various operations (for<br />

example, exec) can associate a file descriptor with a particular file.<br />

Some file descriptors are set up at the time the shell starts up. These are the<br />

standard input/output streams:<br />

v Standard input (file descriptor 0)<br />

v Standard output (file descriptor 1)<br />

v Standard error (file descriptor 2)<br />

<strong>Command</strong>s running under the shell can use these descriptors and streams too.<br />

When a command runs under the shell, the streams are normally associated with<br />

your terminal. However, you can redirect these file descriptors to associate them<br />

with other files (so that I/O on the stream takes place on the associated file instead<br />

of your terminal). In fact, the shell lets you redirect the I/O streams associated with<br />

file descriptors 0 through 9, using the following command-line constructs.<br />

564 z/<strong>OS</strong> <strong>V1R9.0</strong> <strong>UNIX</strong> <strong>System</strong> <strong>Services</strong> <strong>Command</strong> Reference

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!