alias 用于设置命令别名
// 错误实例
shuai@ubuntu:~$ alias myls = "ls -l" // 不能有空格
bash: alias: myls: not found
bash: alias: =: not found
bash: alias: ls -l: not found
shuai@ubuntu:~$ alias myls="ls -l" // 正确创建别名
shuai@ubuntu:~$ alias // 显示系统所有别名
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -alF'
alias ls='ls --color=auto'
alias myls='ls -l' // 可以看到自己的别名已经加进来了
shuai@ubuntu:~$ myls // 调用自己的别名指令
total 60
-rw-r--r-- 1 shuai shuai 33 Apr 26 22:20 a.txt
-rw-r--r-- 1 shuai shuai 38 Apr 26 21:17 b.txt
-rw-r--r-- 1 shuai shuai 11 Apr 26 21:13 c.txt
drwxr-xr-x 2 shuai shuai 4096 Apr 26 15:27 Desktop
drwxr-xr-x 2 shuai shuai 4096 Apr 19 18:03 Documents
drwxr-xr-x 2 shuai shuai 4096 Apr 19 18:03 Downloads
-rw-r--r-- 1 shuai shuai 8980 Apr 19 17:37 examples.desktop
-rw-r--r-- 1 shuai shuai 26 Apr 26 21:48 manage.py
drwxr-xr-x 2 shuai shuai 4096 Apr 19 18:03 Music
drwxr-xr-x 2 shuai shuai 4096 Apr 19 18:03 Pictures
drwxr-xr-x 2 shuai shuai 4096 Apr 19 18:03 Public
drwxr-xr-x 2 shuai shuai 4096 Apr 19 18:03 Templates
drwxr-xr-x 2 shuai shuai 4096 Apr 19 18:03 Videos
shuai@ubuntu:~$ ls -l // 别名指令对应的指令
total 60
-rw-r--r-- 1 shuai shuai 33 Apr 26 22:20 a.txt
-rw-r--r-- 1 shuai shuai 38 Apr 26 21:17 b.txt
-rw-r--r-- 1 shuai shuai 11 Apr 26 21:13 c.txt
drwxr-xr-x 2 shuai shuai 4096 Apr 26 15:27 Desktop
drwxr-xr-x 2 shuai shuai 4096 Apr 19 18:03 Documents
drwxr-xr-x 2 shuai shuai 4096 Apr 19 18:03 Downloads
-rw-r--r-- 1 shuai shuai 8980 Apr 19 17:37 examples.desktop
-rw-r--r-- 1 shuai shuai 26 Apr 26 21:48 manage.py
drwxr-xr-x 2 shuai shuai 4096 Apr 19 18:03 Music
drwxr-xr-x 2 shuai shuai 4096 Apr 19 18:03 Pictures
drwxr-xr-x 2 shuai shuai 4096 Apr 19 18:03 Public
drwxr-xr-x 2 shuai shuai 4096 Apr 19 18:03 Templates
drwxr-xr-x 2 shuai shuai 4096 Apr 19 18:03 Videos
shuai@ubuntu:~$ unalias myls // 删除别名
shuai@ubuntu:~$ alias
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -alF'
alias ls='ls --color=auto'