随笔分类 - shell脚本
摘要:1 函数调用 $(<function> <arguments>)#或${<function> <arguments>} 2 wildcard函数调用 $(wildcard <PATTERN...>) #用于获取匹配该模式下的所有文件列表 $(wildcard *.cpp *.c) 3 patsubs
阅读全文
摘要:在Shell中,可以使用ANSI转义码来控制文本的颜色和格式。ANSI转义码以\033[开头,后面跟着相应的控制字符来改变文本的样式和颜色。 以下是一些常用的Shell颜色代码: 文本颜色: 30: 黑色 31: 红色 32: 绿色 33: 黄色 34: 蓝色 35: 紫色 36: 青色 37: 白
阅读全文
摘要:KILL ^U 丢弃当前行 WEARSE ^W 擦除一个字 ^R 输入指定的字符搜索历史命令 START ^S 暂停终端输出 STOP ^Q 恢复之前暂停的输出
阅读全文
摘要:for myi in 0 1 2 ; do eval mvar$myi=$myidone myi=1eval newvar="\$mvar$myi"echo $newvar eval newvar="\$mvar0"echo $newvar eval mvar0=0eval mvar1=2eval
阅读全文
摘要:1 && a && b #a为真才执行b || a || b #a为假才执行bping -c1 www.baidu.com && echo "ok" || echo "no"2. expect perl java python shell3. cat 1.txt >> 2.txt4. python
阅读全文
摘要:1 && ||ping -c1 www.baidu.com && echo "ok" || echo "no"2. expect perl java python shell3. cat 1.txt >> 2.txt4. python << -EOF(JWW)print "hello"EOF5. .
阅读全文
摘要:busybox sh 是ash InputFile="ip.txt" while IFS= read -r line <&3; do printf '%s\n' "$line" done 3< "$InputFile"https://unix.stackexchange.com/questions/
阅读全文
摘要:#!/bin/bashfile=ip.txti=0for line in `cat ip.txt`do array[$i]=$line let i+=1done for (( i=0;i<${#array[@]};i++))#数组长度do echo ${array[i]}done
阅读全文
摘要:sudo sed -i "s/\/usr\/local/\/tools\/gstreamer1.20.2\/usr\/local/g" `grep prefix -rl .` 路径符/ 要转义\/ sudo sed -i "s/\/tools\/gstreamer1.20.2\/tools\/gst
阅读全文
摘要:egrep "12" 1.txt == grep -E "12" 1.txt fgrep "23" 1.txt == grep -F "12" 1.txt tee 3.txt //读取标准输入,输出成文件 cmp 1.txt 2.txt cut -c1-1 1.txt 显示每列的第几到第几的字符
阅读全文
摘要:1.set -x 或set xtrace 会显示+以及脚本中的内容(执行的部分,没执行的不显示) set -xv(脚本中所有的内容都显示,包括没执行的部分) 2.debug=3 //多层级调试 test $debug -gt 0 && echo "a"test $debug -gt 1 && ech
阅读全文