Linux Cmd Tool 系列之—alias

本文介绍如何使用alias和unalias命令来简化bash shell会话中的命令输入,包括设置和取消别名的方法,以及一些实用的例子。文章还介绍了如何在用户的~/.bashrc文件中配置持久化的别名,并说明了如何使更改立即生效。

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

转载于:https://www.cnblogs.com/moong/p/5904566.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值