{"id":87,"date":"2023-07-20T14:41:24","date_gmt":"2023-07-20T06:41:24","guid":{"rendered":"https:\/\/guoyingxu.cn\/?p=87"},"modified":"2023-07-25T13:16:13","modified_gmt":"2023-07-25T05:16:13","slug":"%e5%ad%a6%e4%b9%a0%e7%ac%94%e8%ae%b0","status":"publish","type":"post","link":"https:\/\/guoyingxu.cn\/?p=87","title":{"rendered":"\u5b66\u4e60\u7b14\u8bb0"},"content":{"rendered":"\n<!doctype html>\n<html>\n<head>\n<meta charset='UTF-8'><meta name='viewport' content='width=device-width initial-scale=1'>\n<title><\/title>\n<\/head>\n<body>\n<pre><code class='language-shell' lang='shell'>\u76d1\u63a7\u53d6\u503c\n=============================================\n#\u63d0\u53d6\u5f53\u524d\u65e5\u671f \ntoday=`date -d &quot;0 day&quot; +%Y\u5e74%m\u6708%d\u65e5%H:%M`\ntoday=`date -d &quot;0 day&quot; +%Y-%m-%d--%H:%M:%S`\n2021\u5e7409\u670828\u65e510:54\n\n#\u63d0\u53d6\u672c\u670d\u52a1\u5668\u7684IP\u5730\u5740\u4fe1\u606f  \nIP=`ifconfig eth0 | grep &quot;inet &quot;|awk &#39;{print $2}&#39;`  \n#\u63d0\u53d6\u670d\u52a1\u5668\u5185\u5b58\u4fe1\u606f\nusedMemP=$(free | awk &#39;\/Mem\/{printf(&quot;%.2f%\\n&quot;), $3\/$2*100}&#39; | sed &quot;s\/\\..*\/\/g&quot;)\n#\u63d0\u53d6\u670d\u52a1\u5668\u78c1\u76d8\u4fe1\u606f\nresult=$(df -Ph | grep -v Filesystem | grep -v \u6587\u4ef6\u7cfb\u7edf | awk &#39;{print $5,$6}&#39; | awk -F &quot;%&quot; &#39;{if($1&gt;=strtonum(&quot;&#39;${max_percent}&#39;&quot;)){print $2,$1&quot;%&quot;}}&#39;)\uff1a\n#\u53d6\u5f53\u524d\u7a7a\u95f2cpu\u767e\u4efd\u6bd4\u503c\uff08\u53ea\u53d6\u6574\u6570\u90e8\u5206\uff09  \ncpu_idle=`top -b -n 1 | grep Cpu | awk &#39;{print $8}&#39; | cut -f 1 -d &quot;.&quot;`  \nusedCpuP=`top -b -n1 | fgrep &quot;Cpu(s)&quot; | tail -1 | awk -F&#39;id,&#39; &#39;{split($1, vs, &quot;,&quot;); v=vs[length(vs)]; sub(\/\\s+\/, &quot;&quot;, v);sub(\/\\s+\/, &quot;&quot;, v); printf &quot;%d&quot;, 100-v;}&#39;`\nusedCpuP=$(top -b -n 2 -d 0.02 | grep Cpu | tail -n 1 | awk &#39;{print $2}&#39; | cut -f 1 -d &quot;%&quot; | sed &quot;s\/\\..*\/\/g&quot;)\n\n  \n#\u8bbe\u7f6e\u7a7a\u95f2cpu\u7684\u544a\u8b66\u503c\u4e3a20%\uff0c\u5982\u679c\u5f53\u524dcpu\u4f7f\u7528\u8d85\u8fc780%\uff08\u5373\u5269\u4f59\u5c0f\u4e8e20%\uff09\uff0c\u7acb\u5373\u53d1\u90ae\u4ef6\u544a\u8b66  \nif (($cpu_idle &lt; 20)); then  \n      echo &quot;IP\u4e3a $IP \u7684\u817e\u8baf\u4e91\u670d\u52a1\u5668cpu\u5269\u4f59$cpu_idle%\uff0c\u4f7f\u7528\u7387\u5df2\u7ecf\u8d85\u8fc780%\uff0c\u8bf7\u53ca\u65f6\u5904\u7406\u3002&quot; | mutt -s &quot;$IP \u670d\u52a1\u5668CPU\u544a\u8b66&quot;  13330295142@163.com  \nfi\n\n\nTOKEN=&quot;https:\/\/oapi.dingtalk.com\/robot\/send?access_token=Token&quot;\nif [ $days -lt 60 ]; then\n    #\u53bb\u6389file\u7684\u540e\u7f00crt\n    curl ${TOKEN} -H &#39;Content-Type: application\/json&#39; -X POST --data &#39;{&quot;msgtype&quot;:&quot;text&quot;,&quot;text&quot;:{&quot;content&quot;:&quot;\u544a\u8b66\u57df\u540d\uff1a&#39;${file%.crt}&#39;\uff0cSSL\u8bc1\u4e66\u6709\u6548\u671f\u5269\u4f59\uff1a&#39;$days&#39; \u5929\uff01\u6ce8\u610f\u63d0\u524d\u7eed\u7b7e\u66f4\u65b0\u8bc1\u4e66\uff01&quot;} , &quot;at&quot;: {&quot;isAtAll&quot;: true}}&#39;\n    \n fi\n##################\u6279\u91cf\u6dfb\u52a0\u8ba1\u5212\u4efb\u52a1##################\nssh root@192.168.98.170 &quot;(echo &#39;16 4 * * * sh \/home\/script\/a.sh &gt; \/home\/script\/a.log 2&gt;&amp;1&#39; ;crontab -l )|crontab&quot;\n=============================================\n\u6b63\u5219\u8868\u8fbe\u5f0f\u5143\u5b57\u7b26\n=============================================\n^\t\t\u884c\u9996\u5b9a\u4f4d\u7b26\t\t\t\t\t^love\n$\t\t\u884c\u5c3e\u5b9a\u4f4d\u7b26\t\t\t\t\tlove$\n.\t\t\u5339\u914d\u5355\u4e2a\u5b57\u7b26\t\t\t\tl..e\n*\t\t\u5339\u914d\u524d\u5bfc\u7b260\u5230\u591a\u6b21\t\t\tab*love\n.*\t\t\u4efb\u610f\u591a\u4e2a\u5b57\u7b26\t\t\n[]\t\t\u5339\u914d\u6307\u5b9a\u8303\u56f4\u5185\u7684\u4e00\u4e2a\u5b57\u7b26\t[IL]ove&lt;s\n[-]\t\t\u5339\u914d\u6307\u5b9a\u8303\u56f4\u5185\u7684\u4e00\u4e2a\u5b57\u7b26\t[a-z0-9]ove\n[^]\t\t\u5339\u914d\u4e0d\u5728\u6307\u5b9a\u7ec4\u5185\u7684\u5b57\u7b26\t\t[^a0z0-9]obe\n\\\t\t\u7528\u6765\u8f6c\u8bd1\u5143\u5b57\u7b26\t\t\t\tlove\\.\n\\&lt;\t\t\u8bcd\u9996\u5b9a\u4f4d\u7b26\t\t\t\t\t\\&lt;love\n\\&gt;\t\t\u8bcd\u5c3e\u5b9a\u4f4d\u7b26\t\t\t\t\tlove\\&gt;\n\\&gt;\t\t\u8bcd\u5c3e\u5b9a\u4f4d\u7b26\t\t\t\t\tlove\\&gt;\n\\(..\\)\t\u5339\u914d\u7a0d\u540e\u4f7f\u7528\u7684\u5b57\u7b26\u7684\u6807\u7b7e\t:% s\/\\(172.16.130.\\)1\/\\15\/\nx\\{m\\}\t\u5b57\u7b26x\u91cd\u590d\u51fa\u73b0m\u6b21\t\t\to\\{5\\}  grep &#39;o\\{5\\}&#39; u.txt\nx\\{m,\\}\t\u5b57\u7b26x\u91cd\u590d\u51fa\u73b0m\u6b21\u4ee5\u4e0a\t\to\\{5,\\}\nx\\{m,n\\}\u5b57\u7b26x\u91cd\u590d\u51fa\u73b0m\u6b21\u4ee5\u4e0a\t\to\\{5,10\\}\n\n\n=============================================\n\n$ openssl pkcs7 -inform der -in rtm.faw-vw.com.p7b -out rtm.faw-vw.com.p7bcc.p7b\n\nopenssl pkcs7 -print_certs -in  rtm.faw-vw.com.p7b.p7b -out safaricom_b2c_readable.cer\nopenssl pkcs7 -print_certs -in rtm.faw-vw.com.p7b -out safaricom_b2c_readable.cer\n\n\n---------------------vim---------------------\n\u5c06root\u66ff\u6362\u4e3arm\n:%s \/root\/rm\/g\n\u6b63\u5219\u8868\u8fbe\u5f0f\u5c06Tom\u66ff\u6362\u4e3aDavid\n1,$ s\/\\&lt;[Tt]om\\&gt;\/David\/g  \n\u5c0610.18.40.100\u66ff\u6362\u4e3a10.18.40.200\n:%s\/\\(10.18.40.\\)100\/\\1200\/\n:%s#\\(10.18.40\\).100#\\1.200#\n\u66ff\u6362ip\n:%s#\\(10.\\)\\(18.\\)\\(40.\\)100#\\1\\2\\3200#\n\u6ce8\u91ca\u6587\u672c\u52a0#\n:3,9 s\/\\(.*\\)#\\1\/\n\n---------------------vim---------------------\n\n---------------------sed---------------------\nsed &#39;s\/root\/rm\/&#39; passwd\ns\u66ff\u6362root\u641c\u7d22\u5b57\u7b26rm\u66ff\u6362\u7684\u5b57\u7b26 passwd\u4fee\u6539\u7684\u6587\u4ef6\/\u662f\u5206\u9694\u7b26\nsed &#39;s_\/bin\/bash_\/sbin\/nologin_&#39; b.txt    \uff08\u5206\u9694\u7b26\u968f\u610f\uff09\nsed &#39;s\/\\\/bin\\\/bash\/\\\/sbin\\\/nologin\/&#39; b.txt\uff08\u5206\u9694\u7b26\u968f\u610f\uff09\nsed &#39;s\/root\/(&amp;)\/&#39; passwd \uff08\u5339\u914d\u7684\u5b57\u7b26\u4e2d\u6dfb\u52a0\uff08\uff09\uff09\nsed &#39;s\/root\/rm\/g&#39;\t\/g \u66ff\u6362\u6240\u6709\nsed -e &#39;3,5s\/nologin\/bash\/&#39; -e &#39;9,11s\/sbin\/bin\/&#39;  passwd   \uff08\u540c\u65f6\u66ff\u6362\u591a\u4e2a\u5185\u5bb9\u7528-e\uff09\n-e \u66ff\u6362\u591a\u4e2a\nsystemctl status prometheus|sed -n &#39;3p&#39;     \u663e\u793a\u8f93\u51fa\u547d\u4ee4\u7684\u7b2c\u4e09\u884c\u5e76\u6253\u5370(p \u6253\u5370)\nsystemctl status prometheus|sed -n &#39;1,3!p&#39;  \u663e\u793a\u6587\u4ef6\u9664\u524d\u4e09\u884c\u4e4b\u5916\u7684\u5168\u90e8\u5185\u5bb9\nsystemctl status prometheus|sed -n &#39;3,+3p&#39;  \u663e\u793a\u6587\u4ef6\u6307\u5b9a\u884c\u548c\u4e4b\u540e\u6307\u5b9a\u884c\u7684\u5185\u5bb9\nsed -n &#39;3p&#39; passwd  \uff08\u663e\u793a\u6587\u4ef6\u7b2c\u4e09\u884c\u5230\u5c4f\u5e55\u4e2d\uff09\nsed -n &#39;1,3p&#39;  passwd \uff08\u663e\u793a\u6587\u4ef6\u7b2c\u4e00\u5230\u7b2c\u4e09\u884c\u5230\u5c4f\u5e55\u4e2d\uff09\nsed &#39;1i####&#39; passwd (\u5728\u6307\u5b9a\u884c\u540e\u63d2\u5165\u5185\u5bb9)\u5728\u6587\u4ef6\u5f00\u5934\u8fdb\u884c\u63d2\u5165  i\u5728\u6587\u4ef6\u5339\u914d\u4e4b\u524d\u63d2\u5165\nsed &#39;$a1111&#39; 9.txt \t\u5728\u6587\u4ef6\u672b\u5c3e\u63d2\u5165\u5185\u5bb91111\ta\u5728\u6587\u4ef6\u5339\u914d\u4e4b\u540e\u63d2\u5165\nsed -n &#39;99,p&#39; test.txt \u4f7f\u7528sed\u6253\u5370\u7b2c99\u884c\n---------------------sed---------------------\n\nhistory|awk -F &quot; &quot; &#39;{for (i=2;i&lt;=NF;i++)printf(&quot;%s &quot;, $i);print &quot;&quot;}&#39;\nsj=`date`\nping -c1 -W1 www.baidu.com  |grep from  |awk  &#39;{print $1,$2,$3,$4,$5,$6,$7,$8,&quot;&#39;&quot;$sj&quot;&#39;&quot;}&#39;\n---------------------awk---------------------\nawk &#39;BEGIN{print 2\/5} {print&quot;ok&quot;} END{print &quot;ok&quot;}&#39; \/etc\/passwd  \u4e09\u6bb5\u5f0f\u8f93\u51fa begin\u5f00\u59cb\u8f93\u51fa\uff0c\u5185\u5b58\u8f93\u51fa\uff0cend\u7ed3\u675f\u8f93\u51fa\ndate |awk &#39;{print &quot;month:&quot;,$2 &quot;\\nyear&quot; $NF}&#39;  \u683c\u5f0f\u5316\u6253\u5370\nawk \u4e2d\u5f15\u7528shell\u53d8\u91cf\u9700\u8981\u7528&quot;&#39;&quot;$ip&quot;&#39;&quot;\n####\u67e5\u770b\u65e5\u5fd7\ncat rtm_ass.log |egrep &quot;^49.4.25.85|^49.4.25.152&quot; |awk &#39;{print $1,$4,$5,$7,$9,$10,$17,$20,$22,$NF}&#39; |grep &#39;\/prod\/tm\/ocu\/ocuData&#39;|grep &#39;08\/Sep\/2021&#39; |wc -l\nawk -F&#39;:&#39; &#39;{printf&quot;%-15s %-10s %-15s\\n&quot;,$1,$2,$3}&#39; \/etc\/passwd  \u683c\u5f0f\u5316\u8f93\u51fa\u6362\u884c\n%s \u5b57\u7b26\u7c7b\u578b\n%d \u6570\u503c\u7c7b\u578b\n%f \n-\u8868\u793a\u5de6\u5bf9\u9f50\uff0c\u9ed8\u8ba4\u662f\u53f3\u5bf9\u9f50\nprintf\u9ed8\u8ba4\u4e0d\u4f1a\u5728\u884c\u5c3e\u81ea\u52a8\u6362\u884c\uff0c\u52a0\\n\n\nip addr |egrep &#39;\\&lt;inet\\&gt;&#39;|grep -v &#39;127.0.0.1&#39;|awk &#39;{print $2}&#39;|awk -F&#39;\/&#39; &#39;{print $1}&#39;\necho &quot;$name-`ip addr |egrep &#39;\\&lt;inet\\&gt;&#39;|grep -v &#39;127.0.0.1&#39;|awk &#39;{print $2}&#39;|awk -F&#39;\/&#39; &#39;{print $1}&#39;`&quot; \n\nname=&quot;elastic&quot;\necho &quot;$name-`ip addr |egrep &#39;\\&lt;inet\\&gt;&#39;|grep -v &#39;127.0.0.1&#39;|awk &#39;{print $2}&#39;|awk -F&#39;\/&#39; &#39;{print $1}&#39;`&quot; |tee \/etc\/hostname\n\ncat 1 |awk &#39;BEGIN{RS=&quot;:&quot;}{print $0}&#39;  RS\u5c06\u4e00\u884c\u6309\u7167\u5206\u9694\u7b26\u5206\u6210\u591a\u884c\u3002\n1111 2222 3333\t4444\n5555\n666\n\nawk -F: &#39;{if($3&lt;300){print $0}else{print $0}}&#39; \/etc\/passwd   awk if\u5224\u65ad\n\n\n\n---------------------awk---------------------\n\n\u6253\u5f00\u6587\u4ef6\u53e5\u67c4 exec6 &lt;&gt;\/file1 \n\u5173\u95ed\u6587\u4ef6\u53e5\u67c4 exec 6&lt;&amp;-\n\u67e5\u770b\u53e5\u67c4 ll \/proc\/$$\/fd\n\u628a\u5220\u9664\u53e5\u67c4\u62f7\u8d1d\u6210\u4e3a\u6587\u4ef6 cp \/proc\/$$\/fd\/6 \/file1\n\u5f53\u4e00\u4e2a\u6587\u4ef6\u7684FD\u672a\u88ab\u91ca\u653e\u5220\u9664\u539f\u6587\u4ef6\u4e5f\u4e0d\u4f1a\u5f71\u54cdFD\n\n{}&amp; \u540e\u53f0\u8fd0\u884c\u8fdb\u7a0b\n&amp; \u00a0\u8868\u793a\u4efb\u52a1\u5728\u540e\u53f0\u6267\u884c\uff0c\u5982\u8981\u5728\u540e\u53f0\u8fd0\u884credis-server,\u5219\u6709\u00a0 redis-server &amp;\n&amp;&amp; \u8868\u793a\u524d\u4e00\u6761\u547d\u4ee4\u6267\u884c\u6210\u529f\u65f6\uff0c\u624d\u6267\u884c\u540e\u4e00\u6761\u547d\u4ee4 \uff0c\u5982 echo &#39;1\u2018 &amp;&amp; echo &#39;2&#39; \u00a0 \u00a0\n| \u8868\u793a\u7ba1\u9053\uff0c\u4e0a\u4e00\u6761\u547d\u4ee4\u7684\u8f93\u51fa\uff0c\u4f5c\u4e3a\u4e0b\u4e00\u6761\u547d\u4ee4\u53c2\u6570\uff0c\u5982 echo &#39;yes&#39; | wc -l\n|| \u8868\u793a\u4e0a\u4e00\u6761\u547d\u4ee4\u6267\u884c\u5931\u8d25\u540e\uff0c\u624d\u6267\u884c\u4e0b\u4e00\u6761\u547d\u4ee4\uff0c\u5982 cat nofile || echo &quot;fail&quot;\n#\u663e\u793a\u4e0a\u4e00\u6761\u547d\u4ee4\u7684\u8fd4\u56de\u503c\necho $?\n\n\n\n---------------------grep---------------------\nip addr |egrep -o &#39;[1-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}&#39;  (\u53ea\u663e\u793a\u5339\u914d\u7684\u5185\u5bb9)\n\n\ncat 1.txt |grep -v &#39;^$&#39;   \u8fc7\u6ee4\u7a7a\u884c\n---------------------grep---------------------\n\n##########################################################\nwhile \u8bed\u53e5\u7ed3\u6784\nwhile\u6761\u4ef6\u6d4b\u8bd5\ndo\n\t\u5faa\u73af\u4f53\ndone\n==\u5f53\u6761\u4ef6\u6d4b\u8bd5\u6210\u7acb\uff08\u6761\u4ef6\u6d4b\u8bd5\u4e3a\u771f\uff09\n\nuntil \u8bed\u53e5\u7ed3\u6784\nuntil\u6761\u4ef6\u6d4b\u8bd5\ndo\n\t\u5faa\u73af\u4f53\ndone\n==\u5f53\u6761\u4ef6\u6d4b\u8bd5\u6210\u7acb\uff08\u6761\u4ef6\u6d4b\u8bd5\u4e3a\u5047\uff09\n\n#####################\u65f6\u95f4################################\ncp -rp prometheus.yml prometheus.yml`date &quot;+%y-%m-%d-%H-%M&quot;`\n#####################\u65f6\u95f4################################\n\n#!\/usr\/bin\/bash\nread ip\nif\tping -c1 $ip &amp;&lt;\/dev\/null ;then\n\techo &quot;$ip is butong&quot;\nelse\n\techo &quot;$ip is tong&quot;\nfi\n--------------------------------\n#!\/usr\/bin\/bash\nip=192.168.1.1\nping -c1 $ip &gt;\/dev\/null;\nif [ $? eq 0] ;then\n\techo &quot;$ip is butong&quot;\nelse\n\techo &quot;$ip is tong&quot;\nfi\n\nexport ip 1.1.1.1\n--------------------------------\n\u5f39\u6027 MapReduce\n--web.listen-address=&quot;:9700&quot;\nemr-84zq57g5\n\n############\u62f7\u8d1d\u5bc6\u94a5#################\n\n#!\/usr\/bin\/bash\nip=&quot;\n192.168.98.170\n&quot;\npasswd=123456\nfor i in $ip\ndo\n\/usr\/bin\/expect &lt;&lt;EOF\nspawn  ssh-copy-id $i\nexpect {\n&quot;yes\/no&quot; { send &quot;yes\\r&quot;; exp_continue }\n&quot;*password&quot; { send &quot;$passwd\\n&quot;; exp_continue }\n{ send &quot;\\n&quot;}\n}\nEOF\ndone\n###########################\u591a\u91cd\u5b9a\u4e49\u5f15\u7528###########################\nstatus_1=$(echo -n &quot;$i \u72b6\u6001\u4e3a&quot; `ssh root@$i &quot; systemctl status elasticsearch.service|grep Active&quot;`)\n--------------------------------\n#!\/usr\/bin\/bash\n\nJC=`ps -ef |grep -v grep |grep rabbitmq |awk &#39;{print $2}&#39;`\nJCS=`ps -ef |grep rabbitmq |wc -l`\nif [ &quot;$JCS&quot; -ne 5 ]  ;then\n        for line in $JC\ndo\n        kill -9  $line\n        echo  $line;\ndone\n        systemctl start rabbitmq ;\nelse\n        exit;\nfi\n\n-------------\u8de8\u811a\u672c\u8c03\u7528\u51fd\u6570-------------------\n#!\/usr\/bin\/bash\nsource .\/pubilc.sh\nsource  .\/2.sh\necho &quot;$dir_path&quot;\necho &quot;ip is $ip &quot;\necho &quot;$ip2&quot;\n$# \u6ca1\u52a0\u53c2\u6570\n$?  \u4e0a\u4e00\u4e2a\u53c2\u6570\u8fd4\u56de\u503c\nctrl +u   \u91cd\u65b0\u8f93\u5165\nctrl +backspance \u5220\u9664\u9519\u8bef\u5185\u5bb9\n\u6570\u5b571\u5de6\u9762\u7684\u7b26\u53f7\u662f\u5206\u53f7\u7528\u4e8e\u8fdb\u884c\u6267\u884c\u547d\u4ee4\n#bash -vx \u5f00\u542f\u8c03\u8bd5\u6a21\u5f0f\u8fd0\u884c\u547d\u4ee4\n\n\n#!\/usr\/bin\/bash\nip=192.168.98.135\ni=1\nwhile [ $i -le 5 ]\n#i\u7684\u503c\u5c0f\u4e8e\u7b49\u4e8e5\ndo\n        ping -c1 $ip &amp;&gt;\/dev\/null\n        if [ $? -eq 0 ];then\n        echo &quot;$ip&quot;\n        fi\n        let i++\ndone\n######################################################\n#\u5224\u65ad\u53d8\u91cf\u662f\u5426\u4e3a\u7a7a\n#!\/bin\/sh\npara1=\nif [ ! -n &quot;$para1&quot; ]; then\n  echo &quot;IS NULL&quot;\nelse\n  echo &quot;NOT NULL&quot;\nfi\n######################################################\n${#line}  -eq 0   \u5224\u65ad\u7a7a\u884c\n$0 \u811a\u672c\u540d\n$* \u6240\u6709\u7684\u53c2\u6570\n$@ \u6240\u6709\u7684\u53c2\u6570\n$# \u53c2\u6570\u7684\u4e2a\u6570\n$$ \u5f53\u524d\u8fdb\u7a0b\u7684PID\n$! \u4e0a\u4e00\u4e2a\u8fdb\u7a0b\u7684PID\n$? \u4e0a\u4e00\u4e2a\u547d\u4ee4\u7684\u8fd4\u56de\u503c0\u8868\u793a\u6210\u529f\n######################################################\n-eq \u7b49\u4e8e,\u5982:if [ &quot;$a&quot; -eq &quot;$b&quot; ]   \n-ne \u4e0d\u7b49\u4e8e,\u5982:if [ &quot;$a&quot; -ne &quot;$b&quot; ]   \n-gt \u5927\u4e8e,\u5982:if [ &quot;$a&quot; -gt &quot;$b&quot; ]   \n-ge \u5927\u4e8e\u7b49\u4e8e,\u5982:if [ &quot;$a&quot; -ge &quot;$b&quot; ]   \n-lt \u5c0f\u4e8e,\u5982:if [ &quot;$a&quot; -lt &quot;$b&quot; ]   \n-le \u5c0f\u4e8e\u7b49\u4e8e,\u5982:if [ &quot;$a&quot; -le &quot;$b&quot; ]   \n&lt;   \u5c0f\u4e8e(\u9700\u8981\u53cc\u62ec\u53f7),\u5982:((&quot;$a&quot; &lt; &quot;$b&quot;))   \n&lt;=  \u5c0f\u4e8e\u7b49\u4e8e(\u9700\u8981\u53cc\u62ec\u53f7),\u5982:((&quot;$a&quot; &lt;= &quot;$b&quot;))   \n&gt;   \u5927\u4e8e(\u9700\u8981\u53cc\u62ec\u53f7),\u5982:((&quot;$a&quot; &gt; &quot;$b&quot;))   \n&gt;=  \u5927\u4e8e\u7b49\u4e8e(\u9700\u8981\u53cc\u62ec\u53f7),\u5982:((&quot;$a&quot; &gt;= &quot;$b&quot;))   \n-o\uff1aor \n-a\uff1aand\n\n-eq\t\u68c0\u6d4b\u4e24\u4e2a\u6570\u662f\u5426\u76f8\u7b49\uff0c\u76f8\u7b49\u8fd4\u56de true\u3002\t[ $a -eq $b ] \u8fd4\u56de false\u3002\n-ne\t\u68c0\u6d4b\u4e24\u4e2a\u6570\u662f\u5426\u4e0d\u76f8\u7b49\uff0c\u4e0d\u76f8\u7b49\u8fd4\u56de true\u3002\t[ $a -ne $b ] \u8fd4\u56de true\u3002\n-gt\t\u68c0\u6d4b\u5de6\u8fb9\u7684\u6570\u662f\u5426\u5927\u4e8e\u53f3\u8fb9\u7684\uff0c\u5982\u679c\u662f\uff0c\u5219\u8fd4\u56de true\u3002\t[ $a -gt $b ] \u8fd4\u56de false\u3002\n-lt\t\u68c0\u6d4b\u5de6\u8fb9\u7684\u6570\u662f\u5426\u5c0f\u4e8e\u53f3\u8fb9\u7684\uff0c\u5982\u679c\u662f\uff0c\u5219\u8fd4\u56de true\u3002\t[ $a -lt $b ] \u8fd4\u56de true\u3002\n-ge\t\u68c0\u6d4b\u5de6\u8fb9\u7684\u6570\u662f\u5426\u5927\u4e8e\u7b49\u4e8e\u53f3\u8fb9\u7684\uff0c\u5982\u679c\u662f\uff0c\u5219\u8fd4\u56de true\u3002\t[ $a -ge $b ] \u8fd4\u56de false\u3002\n-le\t\u68c0\u6d4b\u5de6\u8fb9\u7684\u6570\u662f\u5426\u5c0f\u4e8e\u7b49\u4e8e\u53f3\u8fb9\u7684\uff0c\u5982\u679c\u662f\uff0c\u5219\u8fd4\u56de true\u3002\t[ $a -le $b ] \u8fd4\u56de true\u3002\n\u5b57\u7b26\u4e32\u8fd0\u7b97\u7b26\n=\t\u68c0\u6d4b\u4e24\u4e2a\u5b57\u7b26\u4e32\u662f\u5426\u76f8\u7b49\uff0c\u76f8\u7b49\u8fd4\u56de true\u3002\t[ $a = $b ] \u8fd4\u56de false\u3002\n!=\t\u68c0\u6d4b\u4e24\u4e2a\u5b57\u7b26\u4e32\u662f\u5426\u4e0d\u76f8\u7b49\uff0c\u4e0d\u76f8\u7b49\u8fd4\u56de true\u3002\t[ $a != $b ] \u8fd4\u56de true\u3002\n-z\t\u68c0\u6d4b\u5b57\u7b26\u4e32\u957f\u5ea6\u662f\u5426\u4e3a0\uff0c\u4e3a0\u8fd4\u56de true\u3002\t[ -z $a ] \u8fd4\u56de false\u3002\n-n\t\u68c0\u6d4b\u5b57\u7b26\u4e32\u957f\u5ea6\u662f\u5426\u4e0d\u4e3a 0\uff0c\u4e0d\u4e3a 0 \u8fd4\u56de true\u3002\t[ -n &quot;$a&quot; ] \u8fd4\u56de true\u3002\n$\t\u68c0\u6d4b\u5b57\u7b26\u4e32\u662f\u5426\u4e3a\u7a7a\uff0c\u4e0d\u4e3a\u7a7a\u8fd4\u56de true\u3002\t[ $a ] \u8fd4\u56de true\u3002\n##########\u8f93\u51fa\u65e5\u671f#############\nyml_dir=&quot;\/usr\/local\/prometheus\/&quot;\nyml_file=&quot;\/usr\/local\/prometheus\/prometheus.yml&quot;\ncp -rp $yml_file &quot;$yml_dir&quot;prometheus.yml.`date &quot;+%y-%m-%d&quot;`\n\n###########shell\u5224\u65ad###########\n-e filename \u5982\u679c filename\u5b58\u5728\uff0c\u5219\u4e3a\u771f \n-d filename \u5982\u679c filename\u4e3a\u76ee\u5f55\uff0c\u5219\u4e3a\u771f \n-f filename \u5982\u679c filename\u4e3a\u5e38\u89c4\u6587\u4ef6\uff0c\u5219\u4e3a\u771f \n-L filename \u5982\u679c filename\u4e3a\u7b26\u53f7\u94fe\u63a5\uff0c\u5219\u4e3a\u771f \n-r filename \u5982\u679c filename\u53ef\u8bfb\uff0c\u5219\u4e3a\u771f \n-w filename \u5982\u679c filename\u53ef\u5199\uff0c\u5219\u4e3a\u771f \n-x filename \u5982\u679c filename\u53ef\u6267\u884c\uff0c\u5219\u4e3a\u771f \n-s filename \u5982\u679c\u6587\u4ef6\u957f\u5ea6\u4e0d\u4e3a0\uff0c\u5219\u4e3a\u771f \n-h filename \u5982\u679c\u6587\u4ef6\u662f\u8f6f\u94fe\u63a5\uff0c\u5219\u4e3a\u771f\n#\u5982\u679c\u6587\u4ef6\u5939\u4e0d\u5b58\u5728\uff0c\u521b\u5efa\u6587\u4ef6\u5939\nif [ ! -d &quot;\/myfolder&quot; ]; then\n  mkdir \/myfolder\nfi\n\nseq \u5e8f\u5217\n\n[root@localhost ~]# seq 3\n1\n2\n3\n\n[root@localhost ~]# seq -f &quot;stu%3g&quot; 3 \nstu  1\nstu  2\nstu  3\n\n[root@localhost ~]# seq -f &quot;%03g&quot; 3\n001\n002\n003\n\n\n#############################\u5b57\u7b26\u4e32\u6bd4\u8f83\u7528\u4e24\u4e2a[[]]\u6216\u8005\u7528===#############################\n#!\/usr\/bin\/bash\nprometheus_status=`systemctl status prometheus |grep Active |awk  &#39;{print $3}&#39; `\nold_status=&quot;(running)&quot;\nif [[ $prometheus_status -eq $old_status ]];then\nif [ $prometheus_status == $old_status ];then\n\n        echo &quot;\u670d\u52a1install\u6210\u529f,\u8bf7\u901a\u8fc7http:\/\/$ip:9090\u8fdb\u884c\u8bbf\u95ee\uff0c\u7a0b\u5e8f\u9000\u51fa\u3002\u3002\u3002&quot;\n        exit\nelse\n        echo &quot;\u670d\u52a1\u5b89\u88c5\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u3002\u3002&quot;\n        exit\nfi\n~      \n\ncat &lt;&lt;EOF\n123\n123\n1\n312\nEOF\n\u8f93\u5165\u78c1\u76d8\u4fe1\u606f\n#!\/usr\/bin\/bash\nip=192.168.1.1\nfor i in ip\ndo\n\tssh $i df -h\ndone\n\n\n\n\n[root@localhost ~]# seq -f &quot;stu%03g&quot; 3\nstu001\nstu002\nstu003\n\n%\u524d\u8fb9\u662f\u56fa\u5b9a\u5b57\u7b26\u4e32\uff0c%\u540e\u662f\u6570\u5b57\u4f4d\u6570\uff0c\u9ed8\u8ba4\u662f0\n%3g\u4ee3\u8868\u4e09\u4f4d\u6570\u5b57\uff0c\u6ca1\u6709\u6570\u5b57\u7528\u7a7a\u683c\u4ee3\u66ff\n%03g\u4ee3\u8868\u4e09\u4f4d\u6570\u5b57\uff0c\u6ca1\u6709\u6570\u5b57\u75280\u4ee3\u66ff\nnohup \/data\/node_exporter\/node_exporter  --web.listen-address=&quot;:19100&quot; &amp;\n\n###############\u540e\u53f0\u6267\u884c###############\nnohup \/var\/lib\/mesos\/mysqlBackup\/20210713010103\/sqldump.sh &amp;\n###############while \u6dfb\u52a0\u7528\u6237###############\n\n#!\/usr\/bin\/bash\nwhile read line\ndo\n        user=`echo $line|awk&#39; {print $1}&#39;`\n        pass=`echo $line|awk&#39; {print $2}&#39;`\n        id $user  &amp;&gt;\/dev\/null\n        if [ $? -eq 0 ];then\n                echo &quot;user $user already exists&quot;\n        else\n                useradd $user\n                echo &quot;$pass&quot; |passwd --stdin $user &amp;&gt;\/dev\/null\n                if [ $? -eq 0 ];then\n                        echo &quot;$user is created.&quot;\n                fi\n        fi\ndone &lt; $1\n\n\n################for\u83b7\u53d6\u6240\u6709\u53c2\u6570################\n#!\/usr\/bin\/bash\n\nfor i in $@\ndo\n\tlet sum=$sum+$i\ndone\necho &quot;$sum&quot;\n######\u66ff\u6362\u6587\u672c#########\nsed -ri \/^123\/c456 1.txt\n\t\t\u4ee5^\u5f00\u5934 c\u4e3a\u66ff\u6362\n\t\t\n#####################################\n\n\u6279\u91cf\u4fee\u6539mysql\u5bc6\u7801\n#!\/usr\/bin\/bash\n#!\/usr\/bin\/expect\nip=&#39;\n192.168.98.138\n192.168.98.157\n&#39;\npasswd=&#39;111111&#39;\nfor i in $ip\ndo\n        \/usr\/bin\/expect &lt;&lt;-EOF  \n        spawn ssh root@$i\n        expect &quot;*password&quot;\n        send &quot;123456\\n&quot;\n        expect &quot;#*&quot;\n        send &quot;mysql -uroot -p123456 -P3306 \\n&quot;\n        send &quot;use mysql; \\n&quot;\n        send &quot;UPDATE user SET Password = PASSWORD(&#39;$passwd&#39;) WHERE user = &#39;root&#39;;\\n&quot;\n        send &quot;FLUSH PRIVILEGES;\\n&quot;\n        send &quot;exit\\n&quot;\n        expect eof\n        EOF\ndone\n\n\n\n###############expect\u53d1\u9001\u7279\u6b8a\u5b57\u7b26######################\n\/usr\/bin\/expect &lt;&lt;-EOF  \n        spawn ssh root@$ip_1\n        expect &quot;#*&quot;\n        send &quot;\/usr\/local\/mongodb\/bin\/mongo --host=$ip_1 --port=27017 \\n&quot;\n        expect &quot;#*&quot;\n        send &quot;$csh \\n&quot;\n        expect &quot;#*&quot;\n        send &quot;rs.add(\\&quot;192.168.98.158\\:27018\\&quot;) \\n&quot;\n        expect &quot;#*&quot;\n        send &quot;rs.addArb(\\&quot;192.168.98.159\\:27019\\&quot;) \\n&quot;\n        expect &quot;#*&quot;\n        send &quot;exit \\n&quot;\n        expect eof\nEOF\n#&quot;\u53f7\u548c:\u53f7\u9700\u8981\u8fdb\u884c\u8f6c\u8bd1\u4e0d\u7136\u4f1a\u51fa\u73b0\u62a5\u9519\u3002\n\n#########################sed\u8bfb\u53d6\u63d2\u5165\u53d8\u91cf############################\n#!\/usr\/bin\/bash\nread -p &quot;\u8bf7\u8f93\u5165\u4e3b\u673a\uff1a&quot; localhost\nread -p &quot;\u8bf7\u8f93\u5165\u670d\u52a1\u540d\u79f0\uff1a&quot; service\nread -p &quot;\u8bf7\u8f93\u5165\u7aef\u53e3\u540d\u79f0\uff1a&quot; port\nsed -ri &quot;1i$localhost $service $port&quot; b.txt\ncat b.txt\n\n\n#########if|elif|else|fi####################################\n#!\/usr\/bin\/bash\nread -p &quot;123131&quot; input\nif [ $input == &quot;y&quot; -o $input == &quot;yes&quot; -o $input == &quot;Y&quot; -o $input == &quot;YES&quot; ];then\n        echo &quot;\u5185\u5bb9\u63d2\u5165\u6210\u529f&quot;\nelif [ $input == &quot;n&quot; -o $input == &quot;no&quot; -o $input == &quot;N&quot; -o $input == &quot;NO&quot; ];then\n        echo &quot;\u63d2\u5165\u5931\u8d25&quot;\nelse\n        echo &quot;...&quot;\nfi\n\n\n####################################\u51fd\u6570####################################\uff08\u5148\u5b9a\u4e49\u5728\u8c03\u7528\uff09\n#!\/bin\/bash\nfactorial() {\nfactorial=1\nfor((i=1;i&lt;=$1;i++))\ndo\n        factorial=$[$factorial * $i]\n\ndone\necho &quot;$factorial&quot;\n}\nfactorial $1\nfactorial $2\nfactorial $3\n[root@gyx-wrok ~]# .\/00.sh 5 8 10\n120\n40320\n3628800\n\n################################return####################################\uff08\u73b0\u5728\u5728255\u6570\u503c\u4ee5\u5185\uff09\n#!\/bin\/bash\nfun2() {\nread -p &quot;enter num: &quot; num\nreturn $[2*$num]\n}\n\nfun2\necho &quot;fun2 return value; $?&quot;\n\n\n################################\u51fd\u6570\u8fd4\u56de\u503c####################################\uff08\u65e0\u9650\u5236\uff09\n#!\/bin\/bash\nfun2() {\nread -p &quot;enter num: &quot; num\necho  $[2*$num]\n}\n\nresult=`fun2`\n#\u5b9a\u4e49\u53d8\u91cf\u63a5\u6536\u51fd\u6570\u53d8\u91cf\necho &quot;fun2 return value; $result&quot;\n################################\u51fd\u6570\u4f4d\u7f6e\u53c2\u6570####################################\n\n#!\/usr\/bin\/bash\nif [ $# -ne 3 ];then\n        echo &quot;usage: `basename $0`&quot;\n        exit\nfi\n\nfun2() {\n        echo &quot;$(($1 * $2 * $3))&quot;\n}\nresult=`fun2 $1 $2 $3`\necho &quot;$result&quot;\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<\/body>\n<\/html>\n","protected":false},"excerpt":{"rendered":"<p>\u76d1\u63a7\u53d6\u503c ============================================= #\u63d0\u53d6\u5f53 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-87","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/guoyingxu.cn\/index.php?rest_route=\/wp\/v2\/posts\/87","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/guoyingxu.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/guoyingxu.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/guoyingxu.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/guoyingxu.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=87"}],"version-history":[{"count":0,"href":"https:\/\/guoyingxu.cn\/index.php?rest_route=\/wp\/v2\/posts\/87\/revisions"}],"wp:attachment":[{"href":"https:\/\/guoyingxu.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=87"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/guoyingxu.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=87"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/guoyingxu.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=87"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}