alias
Aliases
can be created by using the alias command.
The
main purpose of alias is reducing the amount of typing that is necessary for
commands or groups of commands that are long or tedious to type. If
you want to see the entire alias for the session you just need to type alias.
Syntax
alias
[alias_name]="command"
It
makes no difference whether double or single quotes are used when creating an
alias.
Example
If
we want to clear the screen by clear command then alias for it can be set by
below alias command.
alias
c="clear"
So just
by pressing c will serve the purpose of clear command.
Creating multiple aliases simultaneously
We can create multiple aliases just by separating the two alias to be made by semicolon.
Example
alias p="pwd"; l="ls -al"Multiple commands in one alias
Multiple commands can also be included in the same alias by inserting them within the quotation and separating them with semicolons.
Example
The alias cl could be created to first launch
clear command and then immediately launch ls command.alias cl="pwd; ls"
Calling alias within alias
Aliases can be created to call other aliases.
Example
The below example will only work provided
there are two aliases c and l already present.alias cl="c; l"
Example
If we have an alias c for clear previously
defined but we don’t have alias for ls command and if we try cl then it will
first perform clear command followed by the conventional ls command.alias cl="c; ls"
No comments:
Post a Comment