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.

tcsh<br />

password″ rot with !:s/rot/root to correct the spelling of ’root’ (but see “Spelling<br />

correction” on page 631 for a different approach).<br />

There is a special abbreviation for substitutions. ^, when it is the first character on<br />

an input line, is equivalent to !:s^. Thus, we might have said ^rot^root to make the<br />

spelling correction in the previous example. This is the only history substitution<br />

which does not explicitly begin with !.<br />

In csh as such, only one modifier may be applied to each history or variable<br />

expansion. In tcsh, more than one may be used, for example<br />

% mv wumpus.man /usr/man/man1/wumpus.1<br />

% man !$:t:r<br />

man wumpus<br />

In csh, the result would be wumpus.1:r. A substitution followed by a colon may need<br />

to be insulated from it with braces:<br />

> mv a.out /usr/games/wumpus<br />

> setenv PATH !$:h:$PATH<br />

Bad ! modifier: $.<br />

> setenv PATH !{-2$:h}:$PATH<br />

setenv PATH /usr/games:/bin:/usr/bin:.<br />

The first attempt would succeed in csh but fails in tcsh, because tcsh expects<br />

another modifier after the second colon instead of $.<br />

Finally, history can be accessed through the editor as well as through the<br />

substitutions just described. The following commands search for events in the<br />

history list and compile them into the input buffer:<br />

v up-history<br />

v down-history<br />

v history-search-backward<br />

v history-search-forward<br />

v i-search-back<br />

v i-search-fwd<br />

v vi-search-back<br />

v vi-search-fwd<br />

v copy-prev-word<br />

v insert-last-word<br />

The toggle-literal-history editor command switches between the expanded and<br />

literal forms of history lines in the input buffer. expand-history and expand-line<br />

expand history substitutions in the current word and in the entire input buffer<br />

respectively.<br />

Alias substitution<br />

The shell maintains a list of aliases which can be set, unset and printed by the<br />

alias and unalias commands. After a command line is parsed into simple<br />

commands (see “<strong>Command</strong> execution” on page 645) the first word of each<br />

command, left-to-right, is checked to see if it has an alias. If so, the first word is<br />

replaced by the alias. If the alias contains a history reference, it undergoes history<br />

substitution as though the original command were the previous input line. If the<br />

alias does not contain a history reference, the argument list is left untouched.<br />

Thus if the alias for ls were ls -l the command ls /usrwould become ls -l /usr, the<br />

argument list here being undisturbed. If the alias for lookup were grep !^<br />

/etc/passwd then lookup bill would become grep bill /etc/passwd. Aliases can be<br />

640 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!