docker等容器技术
Jenkins等自动构建和部署平台
测试推送
后端升级自动触发接口测试
测试结果自动推送到运维平台决策
3`测试准入机制
4`基本测试手段
5·业务测试
6·测试资产管理jira–> 80%
7·自动化类型
UI自动化-机械臂
web-selenium
安卓
ios
框架选择
多端架构
自动化冒烟
自动化难度
自动化的解决方法-异常广告推广升级
自动遍历-一半的用例可以省掉-提高效率
自动遍历的优势
自动遍历研究
技能
测试右移:发布后的质量监控 第二部分-非功能测试-专项测试
主要集中于 移动端
场景、性能、弱网
接口测试-目标
网络7层与协议
1·协议分析工具
测试用例管理
api管理框架
二 软件开发 瀑布
有现成可以参考
敏捷开发
增量迭代、小步快跑
Devops
架构分析 开源项目-mall
统一建模语言
书籍推荐
google
devops
精准化测试
resources- 植物:
https://plantuml.com/zh/- 包围
Plantuml drill site: https://www.planttext.com/
sonarqube代码自动化审计
shell使用 1·注意自带的变量
2·数组的使用
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 muyan@VMmuyan :~ $ a=(1 2 3 4 5 6 ) muyan@VMmuyan :~ $ echo ${ a[1 ]}2 muyan@VMmuyan :~ $ echo ${ a[3 ]}4 muyan@VMmuyan :~ $ echo ${ a[0 ]}1 muyan@VMmuyan :~ $ echo ${ a[5 ]}6 muyan@VMmuyan :~ $ echo ${ a[@]}1 2 3 4 5 6 muyan@VMmuyan :~ $ echo ${ a[*]}1 2 3 4 5 6 数组的数量 muyan@VMmuyan :~ $ echo ${ 6 muyan@VMmuyan :~ $ which python muyan@VMmuyan :~ $ which pwd /bin/pwd muyan@VMmuyan :~ $ which PWD muyan@VMmuyan :~ $ which home muyan@VMmuyan :~ $ which etc muyan@VMmuyan :~ $ which echo ${ /bin/echo
1·符号的使用
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 特殊符号的使用 双引号用于括起一段字符串值,支持Svar形式的变量替换 单引号也表示其内容是字符串值,不支持转义;通常使用双引号就好 \ 是反斜线,某些情况下表示转义。 $(ls ) 表示执行ls 后的结果。与 `` 【反引号】类似 。不过可以嵌套。 `` 反引号。用法比较独特,代表命令的输出。非常有用。 $(())对变量进行操作。比如相加$((a+b)) $((2 +3 )) (())是整数扩展。把里面的变量当作整数去处理。 ([1..10))等价于 seq 1 10。表示1到10
1·换行符的使用 \n 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 muyan@VMmuyan:~/Desktop$ a="a\ndasdfa" muyan@VMmuyan:~/Desktop$ echo a a muyan@VMmuyan:~/Desktop$ echo $a a\ndasdfa muyan@VMmuyan:~/Desktop$ echo -e $a a dasdfa muyan@VMmuyan:~/Desktop$ a=false muyan@VMmuyan:~/Desktop$ a=true muyan@VMmuyan:~/Desktop$ echo -e "${a} ,\n${b} " true ,false muyan@VMmuyan:~/Desktop$
2·加减乘除 —双括号 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 muyan@VMmuyan:~/Desktop$ a=2;b=3;c=4 muyan@VMmuyan:~/Desktop$ echo $((a+b+c)) 9 muyan@VMmuyan:~/Desktop$ echo $(($a +$b +$c )) 9 muyan@VMmuyan:~/Desktop$ echo $((1 +5 )) 6 muyan@VMmuyan:~/Desktop$ echo $(($a +$b *$c )) 14 muyan@VMmuyan:~/Desktop$ echo $((a+b*c)) 14
文件夹显示颜色 -ls
3·类型 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 muyan@VMmuyan:~/Desktop$ a=2 muyan@VMmuyan:~/Desktop$ echo $((a+1 )) 3 注释被打印 muyan@VMmuyan:~/Desktop$ echo $((a+1 )) 3 注释 无被打印 muyan@VMmuyan:~/Desktop$ echo $((a+1 )) 3 乘法 muyan@VMmuyan:~/Desktop$ a=5 muyan@VMmuyan:~/Desktop$ ((a*5)) muyan@VMmuyan:~/Desktop$ echo $a 5 muyan@VMmuyan:~/Desktop$ ((a=a*5)) muyan@VMmuyan:~/Desktop$ echo $a 25 muyan@VMmuyan:~/Desktop$
前++与后++ 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 muyan@VMmuyan:~/Desktop$ a=6 muyan@VMmuyan:~/Desktop$ ((a=a++));echo $a 6 muyan@VMmuyan:~/Desktop$ echo $a 6 muyan@VMmuyan:~/Desktop$ ((a++));echo $a 7 muyan@VMmuyan:~/Desktop$ ((++a));echo $a 8 muyan@VMmuyan:~/Desktop$ echo $a 8 muyan@VMmuyan:~/Desktop$ ((a--));echo $a 7 muyan@VMmuyan:~/Desktop$ echo $a 7 muyan@VMmuyan:~/Desktop$ ((a++));echo $a 8 muyan@VMmuyan:~/Desktop$ echo $a 8 muyan@VMmuyan:~/Desktop$
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 muyan@VMmuyan:~/Desktop$ d=$((2 /1 )) muyan@VMmuyan:~/Desktop$ echo $d 2 muyan@VMmuyan:~/Desktop$ d=$((2 >1 )) muyan@VMmuyan:~/Desktop$ echo $d 1 muyan@VMmuyan:~/Desktop$ d=$((2 <1 )) muyan@VMmuyan:~/Desktop$ echo $d 0 muyan@VMmuyan:~/Desktop$ echo $? 0 muyan@VMmuyan:~/Desktop$ awk 'BEGIN{print 2/3}' 0.666667 muyan@VMmuyan:~/Desktop$ awk "BEGIN{print 2/3}" 0.666667 muyan@VMmuyan:~/Desktop$
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 muyan@VMmuyan:~/Desktop$ q=1;m=3 muyan@VMmuyan:~/Desktop$ echo ${q} ,${m} 1,3 muyan@VMmuyan:~/Desktop$ a=$((q>m)) muyan@VMmuyan:~/Desktop$ echo a a muyan@VMmuyan:~/Desktop$ echo $a 0 muyan@VMmuyan:~/Desktop$ a=$((q<m)) muyan@VMmuyan:~/Desktop$ echo $a muyan@VMmuyan:~/Desktop$ a=1 muyan@VMmuyan:~/Desktop$ a=$((q<m)) muyan@VMmuyan:~/Desktop$ echo $a 1 muyan@VMmuyan:~/Desktop$ a=$((q>m)) muyan@VMmuyan:~/Desktop$ echo $a 0 muyan@VMmuyan:~/Desktop$
2·字符串的操作
1·字符串的切片 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 muyan@VMmuyan:~/Desktop$ mystr="hello welcome testhome" muyan@VMmuyan:~/Desktop$ echo $mystr muyan@VMmuyan:~/Desktop$ echo ${mystr} hello welcome testhome muyan@VMmuyan:~/Desktop$ echo ${mystr:6} welcome testhome muyan@VMmuyan:~/Desktop$ echo ${mystr:6} welcome testhome muyan@VMmuyan:~/Desktop$ echo ${s:6:0} muyan@VMmuyan:~/Desktop$ echo ${s:6:1} w muyan@VMmuyan:~/Desktop$ echo ${s:6:2} we muyan@VMmuyan:~/Desktop$ echo ${s:6:10} welcome te muyan@VMmuyan:~/Desktop$ echo ${s:6:-1} welcome testhom muyan@VMmuyan:~/Desktop$ echo ${s:6:-4} welcome test muyan@VMmuyan:~/Desktop$
直接掐头去尾 1 2 3 4 5 6 7 8 muyan@VMmuyan:~/Desktop$ echo ${str:6:-1} welcome testhom muyan@VMmuyan:~/Desktop$ echo ${str:6:-4} welcome test muyan@VMmuyan:~/Desktop$
2·#删除之前的字符串–#*m 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 muyan@VMmuyan:~/Desktop$ str="hello welcome testhome" muyan@VMmuyan:~/Desktop$ echo ${str} hello welcome testhome muyan@VMmuyan:~/Desktop$ echo ${#str} 22 muyan@VMmuyan:~/Desktop$ echo ${str#hello} welcome testhome muyan@VMmuyan:~/Desktop$ echo ${str#*m} e testhome muyan@VMmuyan:~/Desktop$ muyan@VMmuyan:~/Desktop$ echo ${str##*m} e muyan@VMmuyan:~/Desktop$
%删除之后的字符串–%m* 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 muyan@VMmuyan:~/Desktop$ echo ${str} hello welcome testhome muyan@VMmuyan:~/Desktop$ echo ${str%me} hello welcome testho muyan@VMmuyan:~/Desktop$ echo ${str%thome} hello welcome tes muyan@VMmuyan:~/Desktop$ echo ${str%*h} hello welcome testhome muyan@VMmuyan:~/Desktop$ echo ${str%%*m} hello welcome testhome muyan@VMmuyan:~/Desktop$ echo ${str%%m*} hello welco muyan@VMmuyan:~/Desktop$ echo ${str%%*o} hello welcome testhome muyan@VMmuyan:~/Desktop$ echo ${str%%o*} hell muyan@VMmuyan:~/Desktop$
文本替换 1 2 3 4 muyan@VMmuyan:~/Desktop$ echo ${str/home/love} hello welcome testlove muyan@VMmuyan:~/Desktop$
3·布尔类型 1·命令结果正确 1 2 3 4 5 6 7 8 9 10 11 muyan@VMmuyan:~/Desktop$ ls 1.sh test text.txt x.sh muyan@VMmuyan:~/Desktop$ echo `ls 1.sh` 1.sh muyan@VMmuyan:~/Desktop$ echo $? 0 muyan@VMmuyan:~/Desktop$ ls dsafsadfls : cannot access 'dsafsadf' : No such file or directory muyan@VMmuyan:~/Desktop$ echo $? 2
true–> 0 与 false–> 1 1 2 3 4 5 6 7 muyan@VMmuyan :~/Desktop $ true muyan@VMmuyan :~/Desktop $ echo $? 0 muyan@VMmuyan :~/Desktop $ false muyan@VMmuyan :~/Desktop $ echo $? 1 muyan@VMmuyan :~/Desktop $
4·判断的类型 1·等式计算-算数的判断;echo $? equal 等于
not equal to 不等于
Greater than 大于
Greater than equal 大于等于
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 69 70 muyan@VMmuyan:~/Desktop$ a=$ [ 2 -eq 3 ] muyan@VMmuyan:~/Desktop$ echo $? 1 muyan@VMmuyan:~/Desktop$ echo $a muyan@VMmuyan:~/Desktop$ echo ${a} muyan@VMmuyan:~/Desktop$ a=true muyan@VMmuyan:~/Desktop$ echo ${a} true muyan@VMmuyan:~/Desktop$ [ 2 -eq 2 ] muyan@VMmuyan:~/Desktop$ echo $? 0 muyan@VMmuyan:~/Desktop$ echo $! muyan@VMmuyan:~/Desktop$ echo $* muyan@VMmuyan:~/Desktop$ a=$ [ 2 -eq 2 ] muyan@VMmuyan:~/Desktop$ echo $? 0 muyan@VMmuyan:~/Desktop$ a=$ [ 2 -ne 2 ] muyan@VMmuyan:~/Desktop$ echo $? 1 muyan@VMmuyan:~/Desktop$ a=$ [ 2 -le 2 ] muyan@VMmuyan:~/Desktop$ echo $? 0 muyan@VMmuyan:~/Desktop$ a=$ [ 2 -le 1 ] muyan@VMmuyan:~/Desktop$ echo $? 1 muyan@VMmuyan:~/Desktop$ a=$ [ 2 -ge 1 ] muyan@VMmuyan:~/Desktop$ echo $? 0 muyan@VMmuyan:~/Desktop$ a=$ [ 2 -ge 3 ] muyan@VMmuyan:~/Desktop$ echo $? 1 muyan@VMmuyan:~/Desktop$ a=$ [ 2 -gt 3 ] muyan@VMmuyan:~/Desktop$ echo $? 1 muyan@VMmuyan:~/Desktop$ a=$ [ 2 -gt 1 ] muyan@VMmuyan:~/Desktop$ echo $? 0 muyan@VMmuyan:~/Desktop$ a=$ [ 2 -lt 1 ] muyan@VMmuyan:~/Desktop$ echo $? 1 muyan@VMmuyan:~/Desktop$ a=$ [ 2 -lt 3 ] muyan@VMmuyan:~/Desktop$ a=$ [ 2 -lt 3 ] muyan@VMmuyan:~/Desktop$ echo $? 0 muyan@VMmuyan:~/Desktop$ a=$ [ 2 -ge 1 -a 3 -le 4 ] muyan@VMmuyan:~/Desktop$ echo $? 0 muyan@VMmuyan:~/Desktop$ a=$ [ 2 -ge 1 -a 3 -ge 4 ] muyan@VMmuyan:~/Desktop$ echo $? 1 muyan@VMmuyan:~/Desktop$ a=$ [ 2 -ge 1 -o 3 -ge 4 ] muyan@VMmuyan:~/Desktop$ echo $? 0 muyan@VMmuyan:~/Desktop$ a=$ [ 2 -ge 1 -o 3 -ge 4 ];echo $? muyan@VMmuyan:~$ [ 2 -ge 3 ];echo $? 1 muyan@VMmuyan:~$ muyan@VMmuyan:~$ [ ! 2 -ge 3 ];echo $? 0 muyan@VMmuyan:~$
2·逻辑判断 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 muyan@VMmuyan:~$ [ 2 -ge 1 -a 1 -ge 5 ];echo $? 1 muyan@VMmuyan:~$ [ 2 -ge 1 -a 1 -ge 0 ];echo $? 0 muyan@VMmuyan:~$ [[ 2 -ge 1 || 1 -ge 0 ]];echo $? 0 muyan@VMmuyan:~$ [[ 2 -ge 1 && 1 -ge 0 ]];echo $? 0 muyan@VMmuyan:~$ muyan@VMmuyan:~$ [ ! 2 -ge 3 ];echo $? 0 muyan@VMmuyan:~$ muyan@VMmuyan:~$ [ ! 2 -ge 1 -a 1 -ge 0 ];echo $? 1 muyan@VMmuyan:~$
2`1长串与或非 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 muyan@VMmuyan :~/Desktop $ echo "1" && echo "2" || echo "3" || echo "4" && echo "5" || echo "6" && echo "7" && echo "8" || echo "9" 1 2 5 7 8 muyan@VMmuyan :~/Desktop $ echo "1" && echo "2" || echo "3" || echo "4" && echo "5" || echo "6" && echo "7" && echo "8" && echo "9" 1 2 5 7 8 9 muyan@VMmuyan :~/Desktop $
3·内置判断 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 muyan@VMmuyan:~/Desktop$ [ -e 1.sh ];echo $? 0 muyan@VMmuyan:~/Desktop$ [ -d 1.sh ];echo $? 1 muyan@VMmuyan:~/Desktop$ [ -f 1.sh ];echo $? 0 muyan@VMmuyan:~/Desktop$ [ -r 1.sh ];echo $? 0 muyan@VMmuyan:~/Desktop$ [ -s 1.sh ];echo $? 1 muyan@VMmuyan:~/Desktop$ [ -w 1.sh ];echo $? 0 muyan@VMmuyan:~/Desktop$ [ -x 1.sh ];echo $? 1 muyan@VMmuyan:~/Desktop$
4·逻辑控制
5·if结构 if···fi
1 2 3 4 5 6 7 8 9 10 muyan@VMmuyan:~/Desktop$ if [ -e test ];then echo exist;else echo not exist;fi exist muyan@VMmuyan:~/Desktop$ [ -e test ] && echo exist || echo not exist exist muyan@VMmuyan:~/Desktop$
6·ubuntu linux常用的快捷键 7·case结构比较老
8`select结构
9·for循环 1·最近本的 1 2 3 4 5 6 7 8 9 10 11 12 13 muyan@VMmuyan :~/Desktop $ for (( i=0 ;i<10 ;i++ ));do echo $i ;done0 1 2 3 4 5 6 7 8 9 muyan@VMmuyan :~/Desktop $
2·
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 muyan@VMmuyan:~$ a=( a b c d e f ) muyan@VMmuyan:~$ echo ${a[1]} b muyan@VMmuyan:~$ echo ${a[0]} a muyan@VMmuyan:~$ for (( x=0; x<${#a[@]} ;x++ ));do echo ${a[$x]} ;done a b c d e f muyan@VMmuyan:~$ muyan@VMmuyan:~$ for x in ${a[@]} ;do echo $x ;done a b c d e f muyan@VMmuyan:~$ for x in ${#a[@]} ;do echo $x ;done 6 muyan@VMmuyan:~$ for (( x=0; x<${#a[@]} ;x++ ));do echo $x ;done 0 1 2 3 4 5
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 muyan@VMmuyan:~$ for x in `ls `;do echo $x ;done Desktop Documents Downloads Music Pictures Public Templates Videos muyan@VMmuyan:~$ muyan@VMmuyan:~$ a=(aa bb cc dd "dcasfasf" );for (( x=0; x<${#a[@]} ;x++ ));do echo ${a[$x]} ;done aa bb ccdd dcasfasf muyan@VMmuyan:~$ muyan@VMmuyan:~$ a=(aa bb cc dd " dcasf asf" );for (( x=0; x<${#a[@]} ;x++ ));do echo ${a[$x]} ;done aa bb ccdd dcasf asf muyan@VMmuyan:~$
10·while循环 ···
1 2 3 4 5 6 7 8 9 10 11 12 13 muyan@VMmuyan :~ $ i=0 ;while [ $i -lt 10 ];do echo $i ;((i=i+1 ));done0 1 2 3 4 5 6 7 8 9 muyan@VMmuyan :~ $
1·while循环```````“<”小于号把文件输入到循环语句中,然后使用read方法进行读取 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 muyan@VMmuyan:~/Desktop$ while read x;do echo $x ;done <1.sh 1 2 3 4 a b c d m m ds___---1``12`````fa muyan@VMmuyan:~/Desktop$ ls 1 1.sh test text.txt x.sh muyan@VMmuyan:~/Desktop$
···
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 muyan@VMmuyan:~/Desktop$ echo 'hgdjhasgadfjashfsjkldhflwsdj,hfkjladshfgklsdjghbff' >5 muyan@VMmuyan:~/Desktop$ cat 5 hgdjhasgadfjashfsjkldhflwsdj,hfkjladshfgklsdjghbff muyan@VMmuyan:~/Desktop$ echo 'hello 005' <3 hello 005 muyan@VMmuyan:~/Desktop$ cat 3 hgdjhasgf muyan@VMmuyan:~/Desktop$ echo 'hello 005' <2 -bash: 2: No such file or directory muyan@VMmuyan:~/Desktop$
2`想键盘读取一个文字;并且等待回车;然后返回输入的内容 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 muyan@VMmuyan:~/Desktop$ read a;echo $a fdasfdasedfwsedfg fwsdfwedqsfwed fawsdfwse fdasfdasedfwsedfg fwsdfwedqsfwed fawsdfwse muyan@VMmuyan:~/Desktop$ muyan@VMmuyan:~/Desktop$ read -p"plase input word 文本提示内容 :" a;echo $a plase input word :dasd dasd muyan@VMmuyan:~/Desktop$ read -p"plase input word " a;echo $a plase input word dasd dasd muyan@VMmuyan:~/Desktop$ muyan@VMmuyan:~/Desktop$ read -p"plase input word 文本提示内容大飒飒 :" a;echo $a plase input word 文本提示内容大飒飒 :daSDASDDASD daSDASDDASD muyan@VMmuyan:~/Desktop$
3·until
4·退出控制
1 2 3 4 5 6 7 8 9 10 11 12 muyan@VMmuyan:~/Desktop$ for x in *;do echo $x ;if [ -d $x ];then break ;fi ;done 1 1.sh 3 5test muyan@VMmuyan:~/Desktop$ muyan@VMmuyan:~/Desktop$ ls 1 1.sh 3 5 test text.txt x.sh muyan@VMmuyan:~/Desktop$
1·shell运行环境
1·局部变量的使用—在子项目中执行 1 2 3 4 5 6 7 8 9 10 muyan@VMmuyan :~ $ a=ooooooo muyan@VMmuyan :~ $ echo $a ooooooo muyan@VMmuyan :~ $ (a=1212324 );echo $a ooooooo muyan@VMmuyan :~ $ (a=1212324 ;echo $a );echo $a 1212324 ooooooo muyan@VMmuyan :~ $
2`全局变量 1 2 3 4 5 6 7 8 muyan@VMmuyan:~$ a=abc;echo $a abc muyan@VMmuyan:~$ a=abc;{ a=1212324;echo "局部变量a=${a} " ; };echo $"全局变量中的a=${a} " 局部变量a=1212324 全局变量中的a=1212324 muyan@VMmuyan:~$
3·脚本中的程序的pid 1 2 3 4 5 muyan@VMmuyan:~$ echo $$ 6413 muyan@VMmuyan:~$
1 2 3 4 5 6 7 muyan@VMmuyan:~$ sleep 10& [1] 6430 获取最后一个结束的 后台程序pid muyan@VMmuyan:~$ echo $! 6430
4·测试 5·后台睡眠 1 2 3 4 5 6 7 8 9 muyan@VMmuyan :~ $ sleep 10 & [1 ] 6516 muyan@VMmuyan :~ $ jobs [1 ]+ Running sleep 10 & muyan@VMmuyan :~ $ jobs [1 ]+ Done sleep 10 muyan@VMmuyan :~ $ jobs
6·前后台切换 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 muyan@VMmuyan:~$ sleep 100 ^Z [1]+ Stopped sleep 100 muyan@VMmuyan:~$ jobs -l [1]+ Stopped sleep 100 muyan@VMmuyan:~$ fg 1 sleep 100 ^Z [1]+ Stopped sleep 100 muyan@VMmuyan:~$ jobs [1]+ Stopped sleep 100 muyan@VMmuyan:~$ bg 1 [1]+ sleep 100 & muyan@VMmuyan:~$ jobs [1]+ Running sleep 100 & muyan@VMmuyan:~$ fg 1
2·shell环境变量
1·添加环境变量(用户) 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 muyan@VMmuyan:~$ sudo vim .profile if [ -n "$BASH_VERSION " ]; then if [ -f "$HOME /.bashrc" ]; then . "$HOME /.bashrc" fi fi if [ -d "$HOME /bin" ] ; then PATH="$HOME /bin:$PATH " fi if [ -d "$HOME /.local/bin" ] ; then PATH="$HOME /.local/bin:$PATH " fi export PATH=/home/muyan/Desktop/test:$PATH ".profile" 29L, 987C 29,1 È«²¿
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 muyan@VMmuyan:~$ source .profile Ubuntu修改环境变量 修改用户环境变量 ~/.profile ~/.bash_profile 或者 ~./bash_login ~/.bashrc 上述文件在Ubuntu 10.0以前版本不推荐使用。 系统环境变量 /etc/environment /etc/profile /etc/bash.bashrc /etc/profile和 /etc/bash.bashrc在Ubuntu 10.0版本中不推荐使用。 加入环境变量 如想将一个路径加入到$PATH 中,可以像下面这样做(修改/etc/profile): $ sudo nano /etc/profile 在里面加入:export PATH="$PATH :/my_new_path" 你可以自己加上指定的多个路径,中间用冒号隔开。环境变量更改后,在用户下次登陆时生效,如果想立刻生效,则可执行下面的语句:$source /etc/profile 需要注意的是,最好不要把当前路径”./”放到PATH里,这样可能会受到意想不到的攻击。 其他文件的修改方式与此类似,需要注意的是/etc/environment不需要使用export 设置环境变量,其他profile文件需要。
3·安装软件-
4· grep 命令 1·cat grep 文件中找文文本 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 muyan@VMmuyan:~/Desktop/test$ grep -i "test" text.txt test00119 test001178 test001196 test001176 test001156 Test00114 Test00131 Test00211 Test0101 muyan@VMmuyan:~/Desktop/test$ grep "test" text.txt test00119 test001178 test001196 test001176 test001156 muyan@VMmuyan:~/Desktop/test$ grep -i "test" text.txt test00119 test001178 test001196 test001176 test001156 Test00114 Test00131 Test00211 Test0101 muyan@VMmuyan:~/Desktop/test$ cat text.txt | grep -i "119" test00119 test001196 muyan@VMmuyan:~/Desktop/test$ cat text.txt | grep -o "test" test test test test test muyan@VMmuyan:~/Desktop/test$ cat text.txt | grep -i "test" test00119 test001178 test001196 test001176 test001156 Test00114 Test00131 Test00211 Test0101 muyan@VMmuyan:~/Desktop/test$ cat text.txt | grep -io "test" test test test test test Test Test Test Test muyan@VMmuyan:~/Desktop/test$
2·echo grep 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 muyan@VMmuyan :~/Desktop/test $ echo dasdfbvasjzxc zxcazsxcaxqassx |grep "c" dasdfbvasjzxc zxcazsxcaxqassx muyan@VMmuyan :~/Desktop/test $ echo dasdfbvasjzxc zxcazsxcaxqassx |grep "o" muyan@VMmuyan :~/Desktop/test $ echo dasdfbvasjzxc zxcazsxcaxqassx |grep -o "c" c c c muyan@VMmuyan :~/Desktop/test $ echo dasdfbvasjzxc zxcazsxcaxqassx |grep -o "c." c ca ca muyan@VMmuyan :~/Desktop/test $ echo dasdfbvasjzxc zxcazsxcaxqassx |grep -o "c.*" c zxcazsxcaxqassx muyan@VMmuyan :~/Desktop/test $
3·curl baidu.com 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 muyan@VMmuyan:~/Desktop/test$ curl http://www.baidu.com/s?w=mp3 | less % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 muyan@VMmuyan:~/Desktop/test$ curl http://www.baidu.com/s?w=mp3 | grep "结果约" % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 244k 0 244k 0 0 303k 0 --:--:-- --:--:-- --:--:-- 303k hovering_1RCgm"><i class=" c-icon icons_2hrV4"></i>搜索工具</div><span class=" hint_PIwZX c_font_2AD7M">百度为您找到相关结果约100,000,000个</span></div></div></div></div> 100 905k 0 905k 0 0 789k 0 --:--:-- 0:00:01 --:--:-- 789k muyan@VMmuyan:~/Desktop/test$ curl -s http://www.baidu.com/s?w=mp3 | grep " 结果约" #加上 -s可以取消掉 统计记过的表格(-s) hovering_1RCgm" ><i class="c-icon icons_2hrV4" ></i>搜索工具</div><span class="hint_PIwZX c_font_2AD7M" >百度为您找到相关结果约100,000,000个</span></div></div></div></div> muyan@VMmuyan:~/Desktop/test$
4·while read grep -o 搜狗百度 1 2 3 4 5 6 7 8 9 10 11 12 muyan@VMmuyan :~/Desktop/test $ while read x;do echo $x ;done < baidu.keyword mp333 mp444 andriod ios muyan@VMmuyan :~/Desktop/test $ while read k;do echo $k ;curl -s https: //www.sogou.com/web?query=$k ;done < baidu.keyword | grep -o "找到约[0-9,]*条相关结果" 找到约56 ,495 条相关结果 找到约29 ,720 条相关结果 找到约3 ,359 ,946 条相关结果 找到约5 ,115 ,652 条相关结果 muyan@VMmuyan :~/Desktop/test $
5·awk命令 1·echo 文本查找 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 muyan@VMmuyan :~/Desktop/test $ awk muyan@VMmuyan :~/Desktop/test $ echo "123|345|654" 123 |345 |654 muyan@VMmuyan :~/Desktop/test $ echo "123|345|654" | awk -F '|' '{print $0}' 123 |345 |654 muyan@VMmuyan :~/Desktop/test $ echo "123|345|654" | awk -F '|' '{print $1}' 123 muyan@VMmuyan :~/Desktop/test $ echo "123|345|654" | awk -F '|' '{print $2}' 345 muyan@VMmuyan :~/Desktop/test $ echo "123|345|654" | awk -F '|' '{print $3}' 654 muyan@VMmuyan :~/Desktop/test $ echo "123|345|654" | awk -F '|' '{print $4}' muyan@VMmuyan :~/Desktop/test $ echo "123|345|654" | awk -F '|' '{print $-1}' awk: run time error: negative field index $- 1 FILENAME ="-" FNR =1 NR =1 muyan@VMmuyan :~/Desktop/test $
2·awk 正则表达式—特殊符号用 | 用转义符号\代替\ 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 muyan@VMmuyan:~/Desktop/test$ cat file SD5-1][YRSD5-1-2][0203008400028411] 010102 5001][YRSD7-1][YRSD7-1-2][0203008400028411] 010102 5001][YRSD5-1][YRSD5-1-20][14030084000286E7] 010101 5001][YRSD7-1][YRSD7-1-3][03030084000285C0] 010102 5001][YRSD5-1][YRSD5-1-21][1503008400028736] 010101 5001][YRSD7-1][YRSD7-1-4][0403008400028477] 010101 5002][YRSD7-2][YRSD7-2-22][16030010000f072C] 000000 5001][YRSD5-1][YRSD5-1-23][17030010000f06FD] 001A00 5002][YRSD7-2][YRSD7-2-23][17030010000f06FD] 000000 5001][YRSD5-1][YRSD5-1-24][18030010000f0602] 004900 5002][YRSD7-2][YRSD7-2-24][180300380004C7CD] 000000 5002][YRSD7-2][YRSD7-2-25][19030084000287FA] 010102 5001][YRSD7-1][YRSD7-1-9][0903000800078482] 000001 5002][YRSD5-2][YRSD5-2-35][23030084000282A0] 010101 5001][YRSD5-1][YRSD5-1-26][1A030084000287C9] 010101 5002][YRSD5-2][YRSD5-2-36][240300380004C2F1] 000000 5002][YRSD5-2][YRSD5-2-37][25030084000282C6] 010101 5001][YRSD5-1][YRSD5-1-28][1C030010000f0786] 011301 5001][YRSD5-1][YRSD5-1-29][1D030010000f0657] 000000 5002][YRSD5-2][YRSD5-2-39][270300380004C2C2] 000000 5002][YRSD2-2][YRSD2-2-23][17030084000286D4] 010102 5001][YRSD5-1][YRSD5-1-4][040300080007859F] 00003E 5002][YRSD2-2][YRSD2-2-24][180300840002862B] 010102 5001][YRSD5-1][YRSD5-1-4][0403008400028477] 010101 5001][YRSD2-1][YRSD2-1-6][06030010000f05BC] 000700 muyan@VMmuyan:~/Desktop/test$ awk -F'\\]|\\[' '{if($7~/^..0300840002....$/)print $7}' file 0203008400028411 14030084000286E7 03030084000285C0 1503008400028736 0403008400028477 19030084000287FA 23030084000282A0 1A030084000287C9 25030084000282C6 17030084000286D4 180300840002862B 0403008400028477 muyan@VMmuyan:~/Desktop/test$
3·查看密码列表 1 2 3 4 5 6 7 8 cat passwd | awk -F "\\:" '{print $1}' cat passwd | awk -F "\\:" '{print $1,"\t"$3}'
4`awk与grep相结合 1 2 3 4 5 6 7 8 9 10 11 12 13 14 muyan@VMmuyan:~$ curl -s https://www.sogou.com/web?query=多鱼 | grep -o "找到约[0-9,]*条 相关结果" | awk -F "约|条" '{print $0}' 找到约21,485条相关结果 muyan@VMmuyan:~$ muyan@VMmuyan:~$ curl -s https://www.sogou.com/web?query=多鱼 | grep -o "找到约[0-9,]*条 相关结果" | awk -F "约|条" '{print $1}' 找到 muyan@VMmuyan:~$ curl -s https://www.sogou.com/web?query=多鱼 | grep -o "找到约[0-9,]*条 相关结果" | awk -F "约|条" '{print $2}' 21,485 muyan@VMmuyan:~$ curl -s https://www.sogou.com/web?query=多鱼 | grep -o "找到约[0-9,]*条 相关结果" | awk -F "约|条" '{print $3}' 相关结果 muyan@VMmuyan:~$ curl -s https://www.sogou.com/web?query=多鱼 | grep -o "找到约[0-9,]*条 相关结果" | awk -F "约|条" '{print $4}' muyan@VMmuyan:~$
6·awk passwd打印循环 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 muyan@VMmuyan:~/Desktop/test$ cat /etc/passwd | awk -F ":" 'BEGIN{count=0}{name[count]=$1;count++}END{for(i=0;i<NR;i++)print i,name[i]}' 0 root 1 daemon 2 bin 3 sys ```````` 39 gdm 40 muyan 41 sshd
···
1 2 3 4 5 6 7 8 9 10 muyan@VMmuyan:~$ cat /etc/passwd | awk -F ":" 'BEGIN{count=0}{name[count]=$1;count++}END{for(i=0;i<NR;i++)print i+1,name[i]}' 1 root 2 daemon `````` 41 muyan 42 sshd muyan@VMmuyan:~$
7`awk 换行文本前后加上开头与结尾 1 2 3 4 5 6 7 8 9 10 11 muyan@VMmuyan :~/Desktop/test $ echo -e"line1\nline2" | awk 'BEGIN { print "Start" } { } END { print "End" } ' Start End muyan@VMmuyan :~/Desktop/test $ echo -e "line1\nline2" | awk 'BEGIN { print "Start" } { print } END { print "End" } ' Start line1 line2End muyan@VMmuyan :~/Desktop/test $
8·awk grep 百度
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 ```bash muyan@VMmuyan :~ $ echo "cat dog fish cat" | sed "s/cat/duoyu/" duoyu dog fish cat muyan@VMmuyan :~ $ echo "cat dog fish cat" | sed "s/cat/duoyu/g" duoyu dog fish duoyu muyan@VMmuyan :~ $ muyan@VMmuyan :~ $ echo "cat| dog| fish| cat" | sed "s#|#+#g" cat+ dog+ fish+ cat muyan@VMmuyan :~ $ echo "cat| dog| fish| cat" | sed "s/|/+/g" cat+ dog+ fish+ cat muyan@VMmuyan :~ $ cat /etc/passwd | cut -d : -f1,3 | sed 's/:/ - UID: /'
2`文本替换防止手滑 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 muyan@VMmuyan :~/Desktop/test $ cat text.txt.bak test00119 test001178 test001196 test001176 test001156Test00114 Test00131 Test00211 Test0101 hello1asfdfsaHELLOdasdas muyan@VMmuyan :~/Desktop/test $ sed -i.bak "s/test/Test_my_/" text.txt
6·脚本执行的参数设置与显示 1 2 3 4 5 6 7 8 9 10 11 12 13 muyan@VMmuyan:~/Desktop/test$ bash t.sh a b c d e f g 8 9 10 获取脚本执行的参数: t.sh 获取第一个参数:a 获取第二个参数:b 获取参数的个数:10 获取到的参数(str $ *):a b c d e f g 8 9 10 获取到的参数(每一个参数都是一个str): a b c d e f g 8 9 10 获取到的参数(每3个参数都是一个str---c): c 获取到的参数(每4个参数都是一个str---d): d 获取到的参数(每5个参数都是一个str---e): e 获取当前进程的ID号(PID):11494 muyan@VMmuyan:~/Desktop/test$
7·函数 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 gotest () {echo "this is a test function" read -p "var_a=" var_aread -p "var_b=" var_bif [ $var_a -eq $var_b ]then echo "var_a == var_b" elif [ $var_a -gt $var_b ]then echo "var_a > var_b" else echo "var_a < var_b" fi } gotest ~ ~
8`bash总结 1·IP查询 1 2 curl icanhazip.com1 curl ip111.cn
2·tester.com 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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 muyan@VMmuyan:~$ a=`curl -s https://testerhome.com/topics|grep -o 'href="/topics/[0-9]*"' `;echo $a href="/topics/33514" href="/topics/33653" href="/topics/33646" href="/topics/33574" href="/topics/33655" href="/topics/33657" href="/topics/33639" href="/topics/33644" href="/topics/33625" href="/topics/33604" href="/topics/33624" href="/topics/33649" href="/topics/33597" href="/topics/33476" href="/topics/33652" href="/topics/33654" href="/topics/33632" href="/topics/33389" href="/topics/33614" href="/topics/33651" href="/topics/33608" href="/topics/33642" href="/topics/33619" href="/topics/33636" href="/topics/33561" href="/topics/33639" href="/topics/33612" href="/topics/33608" href="/topics/33603" href="/topics/33588" muyan@VMmuyan:~$ muyan@VMmuyan:~$ a=`curl -s https://testerhome.com/topics | grep -o 'href="/topics/[0-9]*"' | awk -F '\/|\"' '{print $4}' `;echo $a 33514 33653 33646 33574 33655 33657 33639 33644 33625 33604 33624 33649 33597 33476 33652 33654 33632 33389 33614 33651 33608 33642 33619 33636 33561 33639 33612 33608 33603 33588 muyan@VMmuyan:~$ muyan@VMmuyan:~$ a=`curl -s https://testerhome.com/topics | grep -o 'href="/topics/[0-9]*"' | awk -F '\/|\"' '{print $4}' `;echo $a ;for id in $a ;do url='https://testerhome.com/topics/' ${id} ;echo $url ;done 33514 33653 33646 33574 33655 33657 33639 33644 33625 33604 33624 33649 33597 33476 33652 33654 33632 33389 33614 33651 33608 33642 33619 33636 33561 33639 33612 33608 33603 33588 https://testerhome.com/topics/33514 https://testerhome.com/topics/33653 https://testerhome.com/topics/33646 https://testerhome.com/topics/33574 `````` `````` `````` zan=`curl -s $url | grep -o -m1 ` a=`curl -s https://testerhome.com/topics | grep -o 'href="/topics/[0-9]*"' | awk -F '\/|\"' '{print $4}' `;echo $a ;for id in $a ;do url='https://testerhome.com/topics/' ${id} ;zan=`curl -s $url | grep -o -m1 '<span>[0-9].*个赞' | awk -F '\>|个赞' '{print $1}' `;echo $zan ;done muyan@VMmuyan:~$ a=`curl -s https://testerhome.com/topics | grep -o 'href="/topics/[0-9]*"' | awk -F '\/|\"' '{print $4}' `;echo $a ;for id in $a ;do url='https://testerhome.com/topics/' ${id} ;zan=`curl -s $url | grep -o -m1 '<span>[0-9].*个赞' | awk -F '\>|个赞' '{print $2}' `;echo $zan ;done 33514 33664 33673 33659 33665 33672 33618 33668 33619 33670 33631 33666 33653 33655 33574 33389 33642 33624 33652 33597 33662 33660 33658 33639 33612 33608 33603 33588 1 10 2 muyan@VMmuyan:~$ a=`curl -s https://testerhome.com/topics | grep -o 'href="/topics/[0-9]*"' | awk -F '\/|\"' '{print $4}' `;echo $a ;for id in $a ;do url='https://testerhome.com/topics/' ${id} ;zan=`curl -s $url | grep -o -m1 '<span>[0-9].*个赞' | awk -F '\>|个赞' '{print $2}' `;echo $zan ;done 33514 33664 33673 33659 33665 33672 33618 33668 33619 33670 33631 33666 33653 33655 33574 33389 33642 33624 33652 33597 33662 33660 33658 33639 33612 33608 33603 33588 1 10 2 muyan@VMmuyan:~$ a=`curl -s https://testerhome.com/topics | grep -o 'href="/topics/[0-9]*"' | awk -F '\/|\"' '{print $4}' `;echo $a ;for id in $a ;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 ; 33514 33674 33619 33659 33673 33639 33675 33664 33665 33672 33618 33668 33670 33631 33666 33653 33655 33574 33389 33642 33624 33652 33597 33639 33612 33608 33603 33588 https://testerhome.com/topics/33514 点赞人数 0 https://testerhome.com/topics/33674 点赞人数 0 https://testerhome.com/topics/33664 点赞人数 1 https://testerhome.com/topics/33665 点赞人数 2 https://testerhome.com/topics/33672 点赞人数 0 muyan@VMmuyan:~$ muyan@VMmuyan:~$ a=`curl -s https://testerhome.com/topics | grep -o 'href="/topics/[0-9]*"' | awk -F '\/|\"' '{print $4}' `;echo $a ;for id in $a ;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}' 33514 33674 33619 33659 33673 33639 33675 33664 33665 33672 33618 33668 33670 33631 33666 33653 33655 33574 33389 33642 33624 33652 33597 33639 33612 33608 33603 33588 33514 点赞人数 0 33674 点赞人数 0 33619 点赞人数 6 33659 点赞人数 10 33673 点赞人数 0 a=`curl -s https://testerhome.com/topics | grep -o 'href="/topics/[0-9]*"' | awk -F '\/|\"' '{print $4}' `;echo $a ;for id in $a ;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 $5}' ; 33597 点赞人数 2 33639 点赞人数 4 33612 点赞人数 0 33608 点赞人数 0 33603 点赞人数 0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 muyan@VMmuyan:~$ for skill in Ada Coffe Action Java; do echo "I am good at ${skill} Script" ;done I am good at AdaScript I am good at CoffeScript I am good at ActionScript I am good at JavaScript muyan@VMmuyan:~$ array=( Ada Coffe Action Java )for skill in $array ; do echo "I am good at ${skill} Script" ;done array=( Ada Coffe Action Java );echo array_length=${#array[@]} ;for skill in ${array[@]} ; do echo "I am good at ${skill} Script" ;done
06-shell基础语法 变量的定义
变量的使用
1 2 3 muyan@VMmuyan :~ $ [ 2 -ne 1 ];echo $? 0
字符串比较
1 Linux 三剑客 { } 全局变量的使用 + 局部变量()的使用+python的使用调用 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 muyan@VMmuyan:~$ a=1;{ a=3; };echo ${a} 3 muyan@VMmuyan:~$ muyan@VMmuyan:~$ a=1;(a=3);echo ${a} 1 muyan@VMmuyan:~$ muyan@VMmuyan:/usr/bin$ echo "print(3*7)" |python 21 muyan@VMmuyan:/usr/bin$