Exporting aliases, Aliases and the .profile file, Reexecuting the .profile file – HP NonStop G-Series User Manual
Page 40: Displaying aliases, Command history
![background image](/manuals/396692/40/background.png)
Exporting Aliases
The shell allows you to export the aliases you create. Aliases that are exported are passed to any
subshells that are created so that when you execute a shell procedure or a new shell, the alias
remains defined. (Variables that are not exported are used only by the current shell process, not
by subshells.)
You can export an alias by using the following command syntax:
alias -x aliasname=command
The -x flag specifies that you wish to export the alias. 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, enclose the whole expression in single quotes.
For example, to export an alias definition for the rm command, enter:
$ alias -x rm='rm -i'
To remove an alias that you’ve exported, use the unalias command:
unalias aliasname
The aliasname entry specifies the alias you wish to remove.
Aliases that you enter and export from the command line are only valid for the current shell session.
To make an alias a permanent part of your environment, you must enter it in the .profile file.
Aliases and the .profile File
When you define an alias in your .profile file, you can use it whenever you start a new shell.
See
.
For example, to define status in your .profile file as the alias for
cd /usr/chang/reports/status
, enter the following line in .profile:
alias status='cd /usr/chang/reports/status'
Before you can use an alias that you enter in the .profile file, you must reexecute .profile.
To remove an alias from the .profile file, delete the line defining it from the .profile file,
save and close the file, and reexecute it.
Reexecuting the .profile File
Before an alias that you’ve entered into .profile will work, you must reexecute the .profile
file. Enter the following command to reexecute the .profile file:
$ . .profile
If you do not have . (dot) defined in your PATH environment variable, you must use the following
command to reexecute .profile:
$ . ./.profile
Displaying Aliases
To display all alias definitions, enter:
$ alias
To display the definition of a particular alias, enter:
$ alias aliasname
The aliasname entry specifies the particular alias for which you are requesting a definition.
Command History
The command-history buffer stores the commands you enter and allows you to display them at any
time. As a result, you can select a previous command, or parts of previous commands, and then
40
The OSS Shell