date
[root@zy ~]
2020-06-20 22:51:47
[root@zy ~]
1592664722
shell
[root@zy ~]
echo "获取脚本执行的参数:$0";
echo "获取的参数的个数:$#";
echo "获取第一个参数:$1";
echo "获取第二个参数:$2";
echo "获取到的参数(str):$*";
echo "获取到的参数(每一个参数都是一个str):$@";
echo "获取当前进程id号(PID):$$";
[root@zy ~]
[root@zy ~]
获取脚本执行的参数:doc.sh
获取的参数的个数:0
获取第一个参数:
获取第二个参数:
获取到的参数(str):
获取到的参数(每一个参数都是一个str):
获取当前进程id号(PID):31978
[root@zy ~]
functest(){
echo "获取脚本执行的参数:$0";
echo "获取的参数的个数:$#";
echo "获取第一个参数:$1";
echo "获取第二个参数:$2";
echo "获取到的参数(str):$*";
echo "获取到的参数(每一个参数都是一个str):$@";
echo "获取当前进程id号(PID):$$";
}
functest a b c d e f g
[root@zy ~]
获取脚本执行的参数:doc.sh
获取的参数的个数:7
获取第一个参数:a
获取第二个参数:b
获取到的参数(str):a b c d e f g
获取到的参数(每一个参数都是一个str):a b c d e f g
获取当前进程id号(PID):4581
[root@zy ~]
23456 点赞人数 2
21805 点赞人数 9
23945 点赞人数 0
...
[root@zy ~]
ids=`curl -s https://testerhome.com/topics|grep -o 'href="/topics/[0-9]*"'|awk -F '"|/' '{print $4}'`
for id in $ids
do
url='https://testerhome.com/topics/'$id
zan=`curl -s $url|grep -o -m1 '<span>[0-9]*'|awk -F '>' '{print $2}'`
if [ -n "$zan" ]
then
echo $url '点赞人数' $zan
else
echo $url '点赞人数' 0
fi
done|awk -F '/' '{print $NF}'
[root@zy ~]
23456 点赞人数 2
21805 点赞人数 9
24157 点赞人数 0
24141 点赞人数 2
24155 点赞人数 0
22600 点赞人数 1
23904 点赞人数 0
23865 点赞人数 8
24138 点赞人数 7
函数
[root@zy ~]
demo(){
echo a
echo b
}
demo
[root@zy ~]
a
b
批量修改文件名
[root@zy test]
检查死链接
curl -s https://www.testing-studio.com/ |grep href|grep -o "https[^\"']*" | while read line;do curl -s -I $line |grep "200" && echo 200 $line || echo ERR $line; done;
json数据访问
[root@zy ~]
24631
查看log
awk '$9~/200/{print $0}' nginx.log 检索状态为200
awk '$9!~/200/{print $0}' nginx.log 检索状态不是200
grep ' 404 | 500 ' a.txt
awk '$9==" 404"' a.txt
grep ' 404 | 500 ' a.txt
去重并排序统计
awk '$9!~/200/{print $0}' nginx.log |sort|uniq -c|sort -nr
tail -fn 100 catalina.out | awk '{gsub(/ ]/,"]");print $13}'
cpu/mem
[root@zy ~]
root 25819 25773 0 00:21 pts/0 00:00:00 grep --color=auto aliyundun
[root@zy ~]
%CPU %MEM
0.0 0.1
[root@zy ~]
%CPU %MEM
0.0 0.1
%CPU %MEM
0.0 0.1
%CPU %MEM
0.0 0.1
[root@zy ~]
2020-06-21 13:15:31 %CPU %MEM 0.0 0.1
2020-06-21 13:15:31 %CPU %MEM 0.0 0.1
2020-06-21 13:15:31 %CPU %MEM 0.0 0.1
2020-06-21 13:15:31 %CPU %MEM 0.0 0.1
[root@zy ~]
2020-07-04 23:45:49 4002 29758 %CPU %MEM 0.4 22.6
2020-07-04 23:45:49 4002 29764 %CPU %MEM 0.4 22.6
2020-07-04 23:45:49 4002 29770 %CPU %MEM 0.4 22.6
2020-07-04 23:45:49 4002 29776 %CPU %MEM 0.4 22.6
2020-07-04 23:45:49 4002 29782 %CPU %MEM 0.4 22.6
[root@zy ~]
[15] 22466
real 0m0.008s
user 0m0.003s
sys 0m0.002s
[15] Exit 6 time curl https:www.dmall.com &>/dev/null
[15] 22470
[root@zy ~]
[root@zy ~]
6.7 22.7 426808 0
1.0 22.7 8884 0
0.0 22.7 5922.67 0
...
[root@zy ~]
图形化
[root@zy ~]
2
3
4
1
3
6'|gnuplot -e "set terminal dumb;plot '<cat' using 1 with line"
6 ++----------+-----------+-----------+----------+-----------+----------+*
+ + + + + '<cat' using 1 *******+
| * |
| * |
5 ++ * ++
| ** |
| * |
| * |
4 ++ *** * ++
| **** * * |
| **** * * |
3 ++ *** * * ++
| *** * ** |
| *** * * |
| *** * ** |
2 ++ *** * * ++
| *** * ** |
| *** * * |
+ *** + + + *+** + +
1 **----------+-----------+-----------+----------*-----------+----------++
0 1 2 3 4 5 6
App shell自动化
monkey -p com.xueqiu.android 500
adb shell uiautomator dump
adb shell "uiautomator dump && cat /sdcard/window_dump.xml"| grep -oE "<node[^>]*>" | grep -v 'resource-id=""' | grep -oE 'bounds=".*?]"'
adb shell input tap x y
adb shell input text xx
adb shell wm size
adb shell
/while true;do input swipe 540 1536 540 576;done;
adb 性能监控
[C:\~]$ adb shell
grus:/ $ while true;do pid=$(ps -ef |grep com.xueqiu.android |head -1|awk '{print $2}');ps -o %cpu -o %mem $pid;done
dumpsys
dumpsys -l
dumpsys cpuinfo|grep xueqiu
dumpsys meminfo|grep xueqiu
ls /proc/$pid