9 ls 10 vi advanced-cache.php 11 cd.. 12 ls 13 w 14 cd.. 15 ls 16 pwd 17 ls .... .. ... 91 hddtemp /dev/sda 92 yum install hddtemp 93 hddtemp /dev/sda 94 hddtemp /dev/sg0 95 hddtemp /dev/sg1 96 smartctl -d ata -A /dev/sda | grep -i temperature 97 smartctl -d ata -A /dev/sg1 | grep -i temperature 98 smartctl -A /dev/sg1 | grep -i temperature 99 sensors
alias ..='cd ..' alias ...='cd ../../../' alias ....='cd ../../../../' alias .....='cd ../../../../' alias.4='cd ../../../../' alias.5='cd ../../../../..' alias bc='bc -l' alias cd..='cd ..' alias chgrp='chgrp --preserve-root' alias chmod='chmod --preserve-root' alias chown='chown --preserve-root' alias cp='cp -i' alias dnstop='dnstop -l 5 eth1' alias egrep='egrep --color=auto' alias ethtool='ethtool eth1'
设定一个别名
bash/zsh语法:
1 2 3
alias c='clear' alias down='sudo /sbin/shutdown -h now'
## 增加一些保护 ## alias rm='rm -i' alias cp='cp -i' alias mv='mv -i'
## Memcached ## alias mcdstats='/usr/bin/memcached-tool 10.10.29.68:11211 stats' alias mcdshow='/usr/bin/memcached-tool 10.10.29.68:11211 display' alias mcdflush='echo "flush_all" | nc 10.10.29.68 11211'
## 默认命令参数 ## alias vi='vim' alias grep='grep --color=auto' alias egrep='egrep --color=auto' alias fgrep='fgrep --color=auto' alias bc='bc -l' alias wget='wget -c' alias chown='chown --preserve-root' alias chmod='chmod --preserve-root' alias chgrp='chgrp --preserve-root' alias rm='rm -I --preserve-root' alias ln='ln -i'
下面是一些额外的OS X Unix bash shell别名:
1 2 3 4 5 6 7 8 9 10
# 从bash打开桌面应用 alias preview="open -a '$PREVIEW'" alias safari="open -a safari" alias firefox="open -a firefox" alias chrome="open -a google\ chrome" alias f='open -a Finder '
# 清理那些.DS_Store文件 alias dsclean='find . -type f -name .DS_Store -delete'
#8: 寡人好色
1 2 3 4 5 6 7 8 9 10 11 12
# 彩色的grep输出 alias grep='grep --color=auto' exportGREP_COLOR='1;33'
# 在屏幕上显示10个最近的历史命令 function ht { history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head }
# host和ping命令的替代 # 接受http:// 或 https:// 或 ftps:// 名称用作域或主机名 _getdomainnameonly(){ local h="$1" local f="${h,,}" # remove protocol part of hostname f="${f#http://}" f="${f#https://}" f="${f#ftp://}" f="${f#scp://}" f="${f#scp://}" f="${f#sftp://}" # remove username and/or username:password part of hostname f="${f#*:*@}" f="${f#*@}" # remove all /foo/xyz.html* f=${f%%/*} # show domain name only echo "$f" }
ping(){ local array=( $@ ) # get all args in an array local len=${#array[@]} # find the length of an array local host=${array[$len-1]} # get the last arg local args=${array[@]:0:$len-1} # get all args before the last arg in$@in an array local _ping="/bin/ping" local c=$(_getdomainnameonly "$host") [ "$t" != "$c" ] && echo "Sending ICMP ECHO_REQUEST to \"$c\"..." # pass args and host $_ping$args$c }
host(){ local array=( $@ ) local len=${#array[@]} local host=${array[$len-1]} local args=${array[@]:0:$len-1} local _host="/usr/bin/host" local c=$(_getdomainnameonly "$host") [ "$t" != "$c" ] && echo "Performing DNS lookups for \"$c\"..." $_host$args$c }