alias [-p] [name[=value] ...]
Define or display aliases 显示或定义别名
命令查询顺序:别名->内部命令->外部命令->hash->$PATH
\COMMAND 或 使用绝对路径,均为使用原始命令,如 \ls 或 /bin/ls
-
示例:
[xzt7566@centos7-test Downloads]$ alias alias egrep='egrep --color=auto' alias fgrep='fgrep --color=auto' alias grep='grep --color=auto' alias l.='ls -d .* --color=auto' alias li='ls -lahi --time-style '\''+%Y/%m/%d %H:%M:%S'\''' alias ll='ls -l --color=auto' alias ls='ls --color=auto' alias vi='vim' alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde' xzt7566@centos7-test ~]$ alias date='date +%Y-%m-%d" "%H:%M:%S' [xzt7566@centos7-test ~]$ date 2019-04-22 15:53:09 alias ld='ls -d *' 定义 ld 为只显示目录.没有转义,所以ld -al等参数均还有效. alias lf="ls -la| grep -v '^d'" 除了目录全显示.有了转义,所以-a、-s等参数无效. echo "alias lal= ' ls -lahi --color=auto ' " >> /home/用户名/.bashrc 将定义的别名永久有效.