传统运维 - 健忘- -

2022-10-26

sed替换换行符

sed ':a;N;$!ba;s/\n/ /g'  /tmp/file

date formate

$(date +%Y%m%d --date=''${date_num}' days ago')

awk累加第一列的值

awk '{a+=$1}END{print a}'

awk变量

awk -F '\t' '$1=="'${instance_id}'" && $5=="Primary"''{print $1}'

while读写文件

while read line
do
    line=($line)
    fir=${line[0]}
    sec=${line[1]}
done
mtr -nr --tcp --port=80 106.15.0.90
tcpdump -i any tcp port 80 and host 106.15.0.90  -w  src.pcap -s 0
curl -o /dev/null -s -w time_namelookup:"\t"%{time_namelookup}"\n"time_connect:"\t\t"%{time_connect}"\n"time_appconnect:"\t"%{time_appconnect}"\n"time_pretransfer:"\t"%{time_pretransfer}"\n"time_starttransfer:"\t"%{time_starttransfer}"\n"time_total:"\t\t"%{time_total}"\n"time_redirect:"\t\t"%{time_redirect}"\n" https://srfiles.xx.com//runstime.d3b03cc.js