|
|
|
@ -1,11 +1,10 @@
|
|
|
|
|
##############################################################################
|
|
|
|
|
# BASH CHEATSHEET (中文速查表) - by skywind (created on 2018/02/14)
|
|
|
|
|
# Version: 16, Last Modified: 2018/02/25 04:16
|
|
|
|
|
# Version: 17, Last Modified: 2018/02/25 04:26
|
|
|
|
|
# https://github.com/skywind3000/awesome-cheatsheets
|
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
|
# 常用快捷键
|
|
|
|
|
##############################################################################
|
|
|
|
@ -639,6 +638,52 @@ lsof -P -i -n | cut -f 1 -d " "| uniq | tail -n +2
|
|
|
|
|
:w !sudo tee > /dev/null %
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
|
# 有用的函数
|
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
|
|
# 自动解压:判断文件后缀名并调用相应解压命令
|
|
|
|
|
function q-extract() {
|
|
|
|
|
if [ -f $1 ] ; then
|
|
|
|
|
case $1 in
|
|
|
|
|
*.tar.bz2) tar -xvjf $1 ;;
|
|
|
|
|
*.tar.gz) tar -xvzf $1 ;;
|
|
|
|
|
*.tar.xz) tar -xvJf $1 ;;
|
|
|
|
|
*.bz2) bunzip2 $1 ;;
|
|
|
|
|
*.rar) rar x $1 ;;
|
|
|
|
|
*.gz) gunzip $1 ;;
|
|
|
|
|
*.tar) tar -xvf $1 ;;
|
|
|
|
|
*.tbz2) tar -xvjf $1 ;;
|
|
|
|
|
*.tgz) tar -xvzf $1 ;;
|
|
|
|
|
*.zip) unzip $1 ;;
|
|
|
|
|
*.Z) uncompress $1 ;;
|
|
|
|
|
*.7z) 7z x $1 ;;
|
|
|
|
|
*) echo "don't know how to extract '$1'..." ;;
|
|
|
|
|
esac
|
|
|
|
|
else
|
|
|
|
|
echo "'$1' is not a valid file!"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# 自动压缩:判断后缀名并调用相应压缩程序
|
|
|
|
|
function q-compress() {
|
|
|
|
|
if [ -n "$1" ] ; then
|
|
|
|
|
FILE=$1
|
|
|
|
|
case $FILE in
|
|
|
|
|
*.tar) shift && tar -cf $FILE $* ;;
|
|
|
|
|
*.tar.bz2) shift && tar -cjf $FILE $* ;;
|
|
|
|
|
*.tar.xz) shift && tar -cJf $FILE $* ;;
|
|
|
|
|
*.tar.gz) shift && tar -czf $FILE $* ;;
|
|
|
|
|
*.tgz) shift && tar -czf $FILE $* ;;
|
|
|
|
|
*.zip) shift && zip $FILE $* ;;
|
|
|
|
|
*.rar) shift && rar $FILE $* ;;
|
|
|
|
|
esac
|
|
|
|
|
else
|
|
|
|
|
echo "usage: q-compress <foo.tar.gz> ./foo ./bar"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
|
# References
|
|
|
|
|
##############################################################################
|
|
|
|
|