Linux Cmd Tool 系列01—alias

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux Cmd Tool 系列01—alias相关的知识,希望对你有一定的参考价值。

The alias cmd list your current aliases. For example :

alias

 

Use alias to shorten a long cmd in current shell session:

alias [name=[command]]

 

Use unalias to remove the alias , or use "\"(back-slash) before command to disable alias.

 

Your ~/.bashrc file might look like:

alias cp=cp ?vi #to prompt when copying if you want to overwrite and will tell you where 
alias rm=rm ?i #Prompts you if you really want to remove it.
alias mv=mv ?i #Prompts you if you are going to overwrite something

System-wide aliases can be put in the /etc/bashrc

If you are already in one shell session and you want to apply the new .bashrc immediately :

source ~/.bashrc

 

Examples:

1. Simplify pathing

alias ..=cd ..
alias ...=cd ../../
alias ....=cd ../../../
alias .....=cd ../../../../

2. Call multiple cmds

alias pl=pwd; ls

3. Call other aliases

alias p="pwd"
alias l="ls -la"
alias l="p; l"

4. Creating two separate aliases simultaneously

alias p="pwd"; l="ls -al"

5. Remove all aliases

unalias -a

以上是关于Linux Cmd Tool 系列01—alias的主要内容,如果未能解决你的问题,请参考以下文章

Linux Cmd Tool 系列之—history & search command history

linux基本功系列之alias

cmder里lspwd自定义的alias等一系列命令都无法使用

cmd设置alias提高效率

Linux常用命令 day day up系列2

linux 学习笔记8 alias