背景: 在配置服务器自启动脚本的时候, 使用systemctl启动的进程或者意外退出或者启动报错,或者出现了其他意外. 但是直接用拉起脚本却可以正常运行....
Continue reading...Adin
==> ERROR: A specified local key could not be updated from a keyserver.
其他报错:error: key “428F7ECC7117F726” could...
Continue reading...Vim Ctrl+I 不起作用, Ctrl+I not working
<C-i> and <Tab> are strictly equivalent. You...
Continue reading...Zsh tab补全忽略.o二进制文件
添加如下一行到~/.zshrc
1 2 3 |
zstyle ':completion:*:*:vim:*:*files' ignored-patterns '*.o' |
参考链接:...
Continue reading...grep 封装 — strfile
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
#!/bin/bash # 脚本作用,封装grep指令,不输出冒号,减少复制打开的障碍,同时最后 # 只输出找到的文件的集合(不重复) black='\033[0;30m' red='\033[0;31m' green='\033[0;32m' brown='\033[0;33m' blue='\033[0;34m' purple='\033[0;35m' cyan='\033[0;36m' gray='\033[0;37m' darkGray='\033[1;30m' lightRed='\033[1;31m' lightGreen='\033[1;32m' yellow='\033[1;33m' lightBlue='\033[1;34m' lightPurple='\033[1;35m' lightCyan='\033[1;36m' white='\033[1;37m' noColor='\033[0m' numOfParameters=$# parameters=$@ checkInput() { if [ $1 -lt 1 ]; then echo echo -e ${brown}'No enough parameters'${noColor} echo exit fi } listFileWhichContainStr() { str=$1 restStr="${@:2}" echo -e ${yellow}'Detail: '${noColor} # -Il to ignore binary file find -type f ! -iname tags -exec grep -Il "$str" $restStr --color=always {} + | awk -F: '{print $1, $2}' | uniq echo echo echo -e ${yellow}'unique file list: '${noColor} fileList=`find -type f ! -iname tags -exec grep -Il "$str" --color=always {} + | awk -F: '{print $1}' | uniq` echo $fileList echo echo -e ${yellow}'line by line output:'${noColor} for f in $fileList do echo -e ${purple}$f${noColor} done; } # main: checkInput $numOfParameters listFileWhichContainStr $parameters |
Continue reading...
echo with color
Shell脚本里加入如下定义:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
black='\033[0;30m' red='\033[0;31m' green='\033[0;32m' brown='\033[0;33m' blue='\033[0;34m' purple='\033[0;35m' cyan='\033[0;36m' gray='\033[0;37m' darkGray='\033[1;30m' lightRed='\033[1;31m' lightGreen='\033[1;32m' yellow='\033[1;33m' lightBlue='\033[1;34m' lightPurple='\033[1;35m' lightCyan='\033[1;36m' white='\033[1;37m' noColor='\033[0m' |
1 2 3 4 |
# 使用时在字符串前连接上需要的颜色,结尾处取消颜色设置,注意echo加上 -e 参数 echo -e {red}"str"${noColor} |
Continue reading...