码迷,mamicode.com
首页 > 系统相关 > 详细

Linux Cmd Tool 系列01—alias

时间:2016-09-25 00:47:33      阅读:236      评论:0      收藏:0      [点我收藏+]

标签:

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

标签:

原文地址:http://www.cnblogs.com/moong/p/5904566.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!