{"id":6194,"date":"2022-04-10T20:06:14","date_gmt":"2022-04-10T12:06:14","guid":{"rendered":"http:\/\/xinyiworld.top\/wordpress\/?p=6194"},"modified":"2023-12-04T15:52:30","modified_gmt":"2023-12-04T07:52:30","slug":"%e5%ad%97%e7%ac%a6%e4%b8%b2","status":"publish","type":"post","link":"http:\/\/xinyiworld.top\/wordpress_it\/?p=6194","title":{"rendered":"\u5b57\u7b26\u4e32"},"content":{"rendered":"<p><a href=\"https:\/\/www.cnblogs.com\/kevingrace\/p\/5996133.html\">https:\/\/www.cnblogs.com\/kevingrace\/p\/5996133.html<\/a><br \/>\n<a href=\"https:\/\/www.bbsmax.com\/A\/B0zqeYaZzv\/\">https:\/\/www.bbsmax.com\/A\/B0zqeYaZzv\/<\/a><\/p>\n<ul>\n<li>\u5224\u65ad\u5b57\u7b26\u4e32\u662f\u5426\u4ee5\u67d0\u4e9b\u5b57\u7b26\u5f00\u5934<br \/>\n<a href=\"https:\/\/devnote.pro\/posts\/10000006301174\">https:\/\/devnote.pro\/posts\/10000006301174<\/a><\/li>\n<\/ul>\n<p><strong>\u65b9\u5f0f1\uff1a\u53cc\u7b49\u4e8e\u53f7== \u6bd4\u8f83<\/strong><\/p>\n<p>\u4f7f\u7528bash\u68c0\u67e5\u5b57\u7b26\u4e32\u662f\u5426\u4ee5\u67d0\u4e9b\u5b57\u7b26\u5f00\u5934\u53ef\u4ee5\u4f7f\u7528\u53cc\u7b49\u4e8e\u53f7==\u6bd4\u8f83<\/p>\n<p><code>[[ $str == h* ]]<\/code><\/p>\n<p>\u793a\u4f8b<\/p>\n<pre><code class=\"language-shell\">str=&quot;hello&quot;\nif [[ $str == h* ]];\nthen\n echo &#039;yes&#039;\nfi<\/code><\/pre>\n<p>\u6709\u4e24\u4e2a\u5730\u65b9\u9700\u8981\u6ce8\u610f\uff1a<\/p>\n<blockquote>\n<p>1.h*\u4e0d\u9700\u8981\u4f7f\u7528\u5f15\u53f7\u62ec\u8d77\u6765\uff0c\u4f7f\u7528\u5f15\u53f7\u62ec\u8d77\u6765\u662f\u76f4\u63a5\u505a\u76f8\u7b49\u6bd4\u8f83<br \/>\n2.\u6bd4\u8f83\u8bed\u53e5\u4f7f\u7528\u53cc\u4e2d\u62ec\u53f7\u62ec\u8d77\u6765\uff0c\u800c\u4e0d\u662f\u4f7f\u7528\u5355\u4e2d\u62ec\u53f7<\/p>\n<\/blockquote>\n<p><strong>\u65b9\u5f0f2:=~\u6b63\u5219\u6bd4\u8f83<\/strong><\/p>\n<p>\u5982\u679c\u4f7f\u7528Bash\u7684\u6b63\u5219<\/p>\n<pre><code class=\"language-shell\">str=&quot;hello&quot;\nif [[ &quot;$str&quot; =~ ^he.* ]]; then\n    echo &quot;yes&quot;\nfi<\/code><\/pre>\n<p>\u4f7f\u7528\u6b63\u5219\u5339\u914d\u5b57\u7b26\u4e32\u7684\u5f00\u5934\u5b57\u7b26\u9700\u8981\u6ce8\u610f\uff1a<\/p>\n<blockquote>\n<p>1.he*\uff1a\u4e0d\u8981\u4f7f\u7528he<em>\uff0c\u8fd9\u91cc\u7684\u661f<\/em>\u53f7\u8868\u793ae\u5b57\u7b260\u5230\u591a\u4e2a\uff0c\u5373h\uff0c\u4ee5\u53caheeee\u90fd\u662f\u6d4b\u8bd5\u901a\u8fc7\u7684<br \/>\n2.he.*\uff1a\u8fd9\u91cc\u53ea\u5141\u8bb8\u5305\u542bhe\u7684\u5b57\u7b26\u4e32\u901a\u8fc7\u6d4b\u8bd5<br \/>\n3.^he.*\uff1a\u8fd9\u4e2a\u8868\u793a\u662f\u4ee5he\u5f00\u5934\u7684\u5b57\u7b26\u4e32\u901a\u8fc7\u68c0\u6d4b<\/p>\n<\/blockquote>\n<ul>\n<li>\u6bd4\u8f83\u76f8\u7b49\u3001\u4e0d\u76f8\u7b49\u65b9\u6cd5\u5c0f\u7ed3<br \/>\n<a href=\"https:\/\/www.cnblogs.com\/zpzp\/p\/15905379.html\">https:\/\/www.cnblogs.com\/zpzp\/p\/15905379.html<\/a><br \/>\n<a href=\"https:\/\/www.jb51.net\/article\/56559.htm\">https:\/\/www.jb51.net\/article\/56559.htm<\/a><br \/>\n<a href=\"https:\/\/blog.csdn.net\/halazi100\/article\/details\/79590706\">https:\/\/blog.csdn.net\/halazi100\/article\/details\/79590706<\/a> \uff08=\u4e0e==\u7684\u533a\u522b\uff09<\/li>\n<\/ul>\n<pre><code class=\"language-shell\">#!\/bin\/sh\n\n#\u6d4b\u8bd5\u5404\u79cd\u5b57\u7b26\u4e32\u6bd4\u8f83\u64cd\u4f5c\u3002\n#shell\u4e2d\u5bf9\u53d8\u91cf\u7684\u503c\u6dfb\u52a0\u5355\u5f15\u53f7\uff0c\u723d\u5f15\u53f7\u548c\u4e0d\u6dfb\u52a0\u7684\u533a\u522b\uff1a\u5bf9\u7c7b\u578b\u6765\u8bf4\u662f\u65e0\u5173\u7684\uff0c\u5373\u4e0d\u662f\u6dfb\u52a0\u4e86\u5f15\u53f7\u5c31\u53d8\u6210\u4e86\u5b57\u7b26\u4e32\u7c7b\u578b\uff0c\n#\u5355\u5f15\u53f7\u4e0d\u5bf9\u76f8\u5173\u91cf\u8fdb\u884c\u66ff\u6362\uff0c\u5982\u4e0d\u5bf9$\u7b26\u53f7\u89e3\u91ca\u6210\u53d8\u91cf\u5f15\u7528\uff0c\u4ece\u800c\u7528\u5bf9\u5e94\u53d8\u91cf\u7684\u503c\u66ff\u4ee3\uff0c\u53cc\u5f15\u53f7\u5219\u4f1a\u8fdb\u884c\u66ff\u4ee3\n#author:tenfyguo\n\nA=&quot;$1&quot;\nB=&quot;$2&quot;\n\necho &quot;\u8f93\u5165\u7684\u539f\u59cb\u503c\uff1aA=$A,B=$B&quot;\n\n#\u5224\u65ad\u5b57\u7b26\u4e32\u662f\u5426\u76f8\u7b49\nif [ &quot;$A&quot; = &quot;$B&quot; ];then\necho &quot;[ = ]&quot;\nfi\n\n#\u5224\u65ad\u5b57\u7b26\u4e32\u662f\u5426\u76f8\u7b49\uff0c\u4e0e\u4e0a\u9762\u7684=\u7b49\u4ef7\nif [ &quot;$A&quot; == &quot;$B&quot; ];then\necho &quot;[ == ]&quot;\nfi\n\n#\u6ce8\u610f:==\u7684\u529f\u80fd\u5728[[]]\u548c[]\u4e2d\u7684\u884c\u4e3a\u662f\u4e0d\u540c\u7684\uff0c\u5982\u4e0b\n\n#\u5982\u679c$a\u4ee5\u201da\u201d\u5f00\u5934(\u6a21\u5f0f\u5339\u914d)\u90a3\u4e48\u5c06\u4e3atrue \nif [[ &quot;$A&quot; == a* ]];then\necho &quot;[[ ==a* ]]&quot;\nfi\n\n#\u5982\u679c$a\u7b49\u4e8ea*(\u5b57\u7b26\u5339\u914d),\u90a3\u4e48\u7ed3\u679c\u4e3atrue\nif [[ &quot;$A&quot; == &quot;a*&quot; ]];then\necho &quot;==\/&quot;a*\/&quot;&quot;\nfi\n\n#File globbing(\u901a\u914d) \u548cword splitting\u5c06\u4f1a\u53d1\u751f, \u6b64\u65f6\u7684a*\u4f1a\u81ea\u52a8\u5339\u914d\u5230\u5bf9\u5e94\u7684\u5f53\u524d\u4ee5a\u5f00\u5934\u7684\u6587\u4ef6\n#\u5982\u5728\u5f53\u524d\u7684\u76ee\u5f55\u4e2d\u6709\u4e2a\u6587\u4ef6\uff1aadd_crontab.sh,\u5219\u4e0b\u9762\u4f1a\u8f93\u51faok\n#if [ &quot;add_crontab.sh&quot; == a* ];then \n#echo &quot;ok&quot;\n#fi\nif [ &quot;$A&quot; == a* ];then\necho &quot;[ ==a* ]&quot;\nfi\n\n#\u5982\u679c$a\u7b49\u4e8ea*(\u5b57\u7b26\u5339\u914d),\u90a3\u4e48\u7ed3\u679c\u4e3atrue\nif [ &quot;$A&quot; == &quot;a*&quot; ];then\necho &quot;==\/&quot;a*\/&quot;&quot;\nfi\n\n#\u5b57\u7b26\u4e32\u4e0d\u76f8\u7b49\nif [ &quot;$A&quot; != &quot;$B&quot; ];then\necho &quot;[ != ]&quot;\nfi\n\n#\u5b57\u7b26\u4e32\u4e0d\u76f8\u7b49\nif [[ &quot;$A&quot; != &quot;$B&quot; ]];then\necho &quot;[[ != ]]&quot;\nfi\n\n#\u5b57\u7b26\u4e32\u4e0d\u4e3a\u7a7a\uff0c\u957f\u5ea6\u4e0d\u4e3a0\nif [ -n &quot;$A&quot; ];then\necho &quot;[ -n ]&quot;\nfi\n\n#\u5b57\u7b26\u4e32\u4e3a\u7a7a.\u5c31\u662f\u957f\u5ea6\u4e3a0.\nif [ -z &quot;$A&quot; ];then\necho &quot;[ -z ]&quot;\nfi\n\n#\u9700\u8981\u8f6c\u4e49&lt;\uff0c\u5426\u5219\u8ba4\u4e3a\u662f\u4e00\u4e2a\u91cd\u5b9a\u5411\u7b26\u53f7\nif [ $A \/&lt; $B ];then\necho &quot;[ &lt; ]&quot;  \nfi\n\nif [[ $A &lt; $B ]];then\necho &quot;[[ &lt; ]]&quot;  \nfi\n\n#\u9700\u8981\u8f6c\u4e49&gt;\uff0c\u5426\u5219\u8ba4\u4e3a\u662f\u4e00\u4e2a\u91cd\u5b9a\u5411\u7b26\u53f7\nif [ $A \/&gt; $B ];then\necho &quot;[ &gt; ]&quot;  \nfi\n\nif [[ $A &gt; $B ]];then\necho &quot;[[ &gt; ]]&quot;  \nfi<\/code><\/pre>\n<ul>\n<li>\u5b57\u7b26\u4e32\u622a\u53d6<br \/>\n<a href=\"https:\/\/www.cnblogs.com\/cl1024cl\/p\/6205586.html\">https:\/\/www.cnblogs.com\/cl1024cl\/p\/6205586.html<\/a><\/li>\n<\/ul>\n<p>\u83b7\u53d6\u6587\u4ef6\u540d\u3001\u540e\u7f00\u540d<\/p>\n<pre><code class=\"language-python\">file=\u201dthisfile.txt\u201d\necho \u201cfilename: ${file%.*}\u201d\necho \u201cextension: ${file##*.}\u201d\n\u8f93\u51fa\uff1a\nfilename: thisfile\nextension: txt<\/code><\/pre>\n<p><a href=\"http:\/\/t.zoukankan.com\/hanxing-p-7599105.html\">http:\/\/t.zoukankan.com\/hanxing-p-7599105.html<\/a><\/p>\n<blockquote>\n<p>\u5efa\u8bae\u4f7f\u7528substr\u7684\u65b9\u5f0f\uff0c\u4f7f\u7528${}\u53ef\u80fd\u5bf9\u4e8e\u4e0d\u540c\u7684\u811a\u672c\u89e3\u91ca\u5668\u6709\u517c\u5bb9\u6027\u95ee\u9898\u3002\u62a5Bad substitution\u95ee\u9898\uff0c\u89c1<a href=\"https:\/\/blog.csdn.net\/simplemethane\/article\/details\/124748777\">https:\/\/blog.csdn.net\/simplemethane\/article\/details\/124748777<\/a><\/p>\n<p>substr\u7684\u7d22\u5f15\u662f\u4ece1\u5f00\u59cb\uff0c\u800c\u4e0d\u662f0.<\/p>\n<\/blockquote>\n<ul>\n<li>\n<p>\u5b57\u7b26\u4e32\u5207\u5272<br \/>\n<code>cut -d &quot;=&quot; -f 2<\/code>   :\u8868\u793a\u5c06\u5176=\u53f7\u4f5c\u4e3a\u5206\u9694\u7b26\uff0c\u9009\u53d6\u5176\u7b2c2\u4e2a\u5b57\u6bb5\uff0c\u6240\u6709\u5c31\u662froot<br \/>\n<a href=\"https:\/\/blog.csdn.net\/liaowenxiong\/article\/details\/119171061\">https:\/\/blog.csdn.net\/liaowenxiong\/article\/details\/119171061<\/a><\/p>\n<\/li>\n<li>\n<p>\u6e05\u9664\u7a7a\u5b57\u7b26\u4e32<br \/>\n<code>echo $VAR | sed &#039;s\/ \/\/g&#039;<\/code><\/p>\n<\/li>\n<li>\n<p>\u6e05\u9664\u56de\u8f66\u7b26\u548c\u6362\u884c\u7b26<\/p>\n<pre><code class=\"language-bash\">cat result.txt | while read line;\ndo\nlet i+=1;\nb=$(echo $line|tr -d &quot;\\n&quot;|tr -d &quot;\\r&quot;);\ndone;<\/code><\/pre>\n<\/li>\n<li>\n<p>\u6bd4\u8f83\u5b57\u7b26\u4e32\u5927\u5c0f<br \/>\n<a href=\"https:\/\/haicoder.net\/shell\/shell-str-greater.html\">https:\/\/haicoder.net\/shell\/shell-str-greater.html<\/a><\/p>\n<\/li>\n<li>\n<p>\u6b63\u5219\u5339\u914d<br \/>\n<a href=\"https:\/\/www.cnblogs.com\/hanxiaoyu\/p\/5759477.html\">https:\/\/www.cnblogs.com\/hanxiaoyu\/p\/5759477.html<\/a><\/p>\n<\/li>\n<li>\n<p>\u5b57\u7b26\u4e32\u8f6c\u6570\u5b57<\/p>\n<pre><code class=\"language-bash\">var=`echo $var| awk &#039;{print int($0)}&#039;`<\/code><\/pre>\n<\/li>\n<li>\n<p>\u6570\u5b57\u8f6c\u5b57\u7b26\u4e32<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"language-bash\">\u76f4\u63a5\u52a0\u5f15\u53f7\u5373\u53ef\uff0c\u4f8b\u5982\n\nvar=1\n\nvar1=&quot;$var&quot; \u8fd9\u6837\u5c31\u8f6c\u5316\u4e86<\/code><\/pre>\n<ul>\n<li>\n<p>\u662f\u5426\u5305\u542b\u5b50\u5b57\u7b26\u4e32<br \/>\n<a href=\"https:\/\/blog.csdn.net\/llm_hao\/article\/details\/126856298\">https:\/\/blog.csdn.net\/llm_hao\/article\/details\/126856298<\/a><\/p>\n<\/li>\n<li>\n<p>\u5224\u7a7a\u4e0e\u975e\u7a7a<br \/>\n<a href=\"https:\/\/blog.csdn.net\/LiLittleCat\/article\/details\/120188514\">https:\/\/blog.csdn.net\/LiLittleCat\/article\/details\/120188514<\/a><\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"language-bash\">\nif [[ str1 = str2 ]]   # \u5f53\u5b57\u7b26\u4e32 str1 \u548c str2 \u6709\u76f8\u540c\u5185\u5bb9\u3001\u957f\u5ea6\u65f6\u4e3a\u771f\n\nif [[ str1 != str2 ]]  # \u5f53\u5b57\u7b26\u4e32 str1 \u548c str2 \u4e0d\u7b49\u65f6\u4e3a\u771f\n\nif [[ -n &quot;str1&quot; ]]       # \u5f53\u5b57\u7b26\u4e32 str1 \u7684\u957f\u5ea6\u5927\u4e8e 0\uff08\u975e\u7a7a\uff09\u65f6\u4e3a\u771f \n\nif [[ -z &quot;str1&quot; ]]       # \u5f53\u5b57\u7b26\u4e32 str1 \u7684\u957f\u5ea6\u4e3a 0\uff08\u7a7a\uff09\u65f6\u4e3a\u771f \n\nif [[ str1 ]]          # \u5f53\u5b57\u7b26\u4e32 str1 \u4e3a\u975e\u7a7a\u65f6\u4e3a\u771f\n<\/code><\/pre>\n<ul>\n<li>\u5224\u65ad\u662f\u5426\u4e3a\u6574\u6570<br \/>\n<a href=\"https:\/\/blog.csdn.net\/mhw666\/article\/details\/91360368\">https:\/\/blog.csdn.net\/mhw666\/article\/details\/91360368<\/a><\/li>\n<\/ul>\n<p><a href=\"https:\/\/blog.csdn.net\/canyudeguang\/article\/details\/53455977\">https:\/\/blog.csdn.net\/canyudeguang\/article\/details\/53455977<\/a><\/p>\n<pre><code class=\"language-bash\">flag=true\nread -p &quot;please input a number:&quot; num\nwhile $flag\ndo\n        len=`echo &quot;$num&quot;|sed &#039;s\/[0-9]\/\/g&#039;|sed &#039;s\/-\/\/g&#039;`\n        [ -n $len ] &amp;&amp; flag=false || read -p &quot;please input a integer:&quot; num\ndone<\/code><\/pre>\n<button class=\"simplefavorite-button\" data-postid=\"6194\" data-siteid=\"1\" data-groupid=\"1\" data-favoritecount=\"0\" style=\"\">\u6536\u85cf <i class=\"sf-icon-star-empty\"><\/i><\/button>","protected":false},"excerpt":{"rendered":"<p>https:\/\/www.cnblogs.com\/kevingrace\/p\/5996133.html  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[740],"tags":[],"_links":{"self":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/6194"}],"collection":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6194"}],"version-history":[{"count":25,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/6194\/revisions"}],"predecessor-version":[{"id":10843,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/6194\/revisions\/10843"}],"wp:attachment":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6194"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6194"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6194"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}