Aliases – HP NonStop G-Series User Manual

Page 39

Advertising
background image

more than one filename or pathname that matches the partial name you entered, the shell lists the
possible matches.

To activate the filename-completion mechanism, define the EDITOR variable in your .profile
file. For example, if you wish to use the vi editor, enter the following variable definition in your
.profile

file:

EDITOR=vi

To demonstrate how filename completion works, assume that your editor is vi and that you have
the following three files in your current directory: salesfeb, salesjan, and salesmar. To
display a long listing and to activate filename completion, enter:

$ ls -l sales<Esc>=

1) salesfeb

2) salesjan

3) salesmar

$ ls -l sales

The system redisplays your command, and your cursor is at the end of sales. Assume that you
wish to choose salesjan. Type the letter a (the vi append command) followed by jan. Then
press the Return key. The listing for salesjan will be displayed.

For more detailed information on filename completion, see the sh(1) reference page either online
or in the Open System Services Shell and Utilities Reference Manual.

Aliases

The command alias feature allows you to abbreviate long command lines or rename commands.
For example, assume that you often need to move to a directory /usr/chang/reports/status.
You can create an alias named status, which will move you to that directory whenever you enter
it on the command line.

In addition, aliases allow you to make up more descriptive names for commands. For example,
you could define an alias named rename for the mv command.

The general format of the alias command is the following:

alias aliasname=command

The aliasname entry specifies the name you wish to use. The command entry specifies either the
original command or a series of commands. If the command has more than one part (has spaces),
enclose the whole expression in single quotes.

For example, to create the alias status that moves you to the directory
/usr/chang/reports/status

, enter:

$ alias status='cd /usr/chang/reports/status'

When you enter the alias status in a command, the shell treats the word status as it would
the command cd /usr/chang/reports/status and changes your working directory to
/usr/chang/reports/status

.

To remove an alias for the current session, use the unalias command. The general format of the
unalias

command is the following:

unalias aliasname

The aliasname entry specifies the alias you wish to remove.

An alias that you define in this manner on the command line is applicable only to the current shell:
it is not passed to any subshells. To make an alias valid in subshells, you must export the alias or
define it in the .profile file.

Aliases

39

Advertising
This manual is related to the following products: