Skip to content

Instantly share code, notes, and snippets.

@ibreathebsb
Created September 1, 2018 08:19
Show Gist options
  • Save ibreathebsb/0660e5acdb32ef5aed3f65bc15159601 to your computer and use it in GitHub Desktop.
Save ibreathebsb/0660e5acdb32ef5aed3f65bc15159601 to your computer and use it in GitHub Desktop.

alias

alias : 列出所有别名

isaac@hp:~/Notes/linux$ 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 another_name=some_command 指定别名:

isaac@hp:~/Notes/linux$ alias saymyname='echo `whoami`'
isaac@hp:~/Notes/linux$ saymyname 
isaac

unalias

unalias some_alias_name: 取消some_alias_name这个别名

isaac@hp:~/Notes/linux$ unalias saymyname 
@ibreathebsb
Copy link
Author

ibreathebsb commented Sep 1, 2018

history

history: 列出所有历史命令

history n: 列出最后n条历史命令

history -c: 清空当前历史记录

history -w : 将历史记录写入~/.bash_history

history -a file: 将历史记录写入file中,若未指定file则默认写入~/.bash_history

!n: 执行第n条历史命令

!command: 查找历史中第一条以command开头的命令并执行

!!: 执行上一条命令

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment