linux 中创建命令别名

 

1、临时创建

root@PC1:/home/test2# ls
a.txt
root@PC1:/home/test2# cat a.txt
j k e
s f g
x v b
root@PC1:/home/test2# alias 'cat=cat -A'      ## 创建命令别名
root@PC1:/home/test2# ls
a.txt
root@PC1:/home/test2# cat a.txt
j k e^M$
s f g^M$
x v b^M$
root@PC1:/home/test2# unalias cat    ## 取消命令别名
root@PC1:/home/test2# ls
a.txt
root@PC1:/home/test2# cat a.txt
j k e
s f g
x v b

 

2、永久创建

root@PC1:/home/test2# ls
a.txt
root@PC1:/home/test2# cat a.txt
j k e
s f g
x v b
root@PC1:/home/test2# echo alias "\"cat=cat -A\"" >> ~/.bashrc
root@PC1:/home/test2# source ~/.bashrc
root@PC1:/home/test2# ls
a.txt
root@PC1:/home/test2# cat a.txt
j k e^M$
s f g^M$
x v b^M$
root@PC1:/home/test2# tail -n 3 ~/.bashrc
#    . /etc/bash_completion
#fi
alias "cat=cat -A"

 

 

posted @ 2022-06-18 12:56  小鲨鱼2018  阅读(174)  评论(0编辑  收藏  举报