|
Article on other languages:
|
In computing, alias is a command in various command line interpreters (shells) such as Unix shells, 4DOS/4NT and Windows PowerShell, which enables a replacement of a word with another string. It is mainly used for abbreviating a system command, or for adding default arguments to a regularly used command. Typically, an alias will last for the life of the shell session but regularly used aliases can be placed in the shell's configuration file (~/.cshrc or the systemwide /etc/csh.cshrc for csh, or ~/.bashrc or the systemwide /etc/bashrc or /etc/bash.bashrc for bash) so that they will be available for all shell sessions.
Creating aliasesAliases can be created by supplying name/value pairs as arguments for the alias command. An example of the Bash shell syntax is: alias copy="cp" The corresponding syntax in the C shell or tcsh shell is: alias copy "cp" This alias means that when the command In the 4DOS/4NT shell the following syntax is used to define alias cp copy To create a new alias in Windows PowerShell, the new-alias ci copy-item This creates a new alias called Viewing currently defined aliasesTo view defined aliases the following commands can be used: alias # Used without arguments; displays a list of all current aliases alias -p # Analogous to the above; not available in 4DOS/4NT and PowerShell alias myAlias # Displays the command for a defined alias Overriding aliasesIn Unix shells, if an alias exists for a command, it is possible to override the alias by surrounding the command with quotes. For example, consider the following alias definition: alias ls='ls -la' To override this alias and execute the 'ls' In Windows PowerShell, the set-alias ci cls The alias Removing aliasesIn Unix shells and 4DOS/4NT, aliases can be removed by executing the unalias copy # Removes the copy alias unalias -a # The -a switch will remove all aliases; not available in 4DOS/4NT In Windows PowerShell, the alias can to be removed from the alias:\ drive using remove-item alias:ci # Removes the ci alias Typical aliasesSome commonly used aliases in the Bash shell: alias ls='ls --color=tty' # use colors alias la='ls -a' # list all files alias ll='ls -l' # long listing format alias rm='rm -i' # prompt before overwrite alias cp='cp -i' alias mv='mv -i' alias vi='vim' # use improved vi editor Standard aliases of Windows PowerShell include: new-alias cd set-location new-alias ls get-childitem new-alias dir get-childitem new-alias echo write-output new-alias ps get-process new-alias kill stop-process AlternativesWhen not using arguments, as in the External links
|
||||||||||||||||||||||||||||||||||||||||||
This article is from Wikipedia. All text is available under the terms of the GNU Free Documentation License.
Mercedes Car
This site monitored by SitePinger.net