{"id":61714,"date":"2025-04-29T12:50:04","date_gmt":"2025-04-29T04:50:04","guid":{"rendered":"https:\/\/fwq.ai\/blog\/61714\/"},"modified":"2025-04-29T12:50:04","modified_gmt":"2025-04-29T04:50:04","slug":"%e4%bd%bf%e7%94%a8-bash-%e5%88%b6%e4%bd%9c-web-%e5%ae%89%e5%85%a8%e9%a2%9c%e8%89%b2-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/61714\/","title":{"rendered":"\u4f7f\u7528 Bash \u5236\u4f5c Web \u5b89\u5168\u989c\u8272"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/887\/227\/168872725081595.jpg\" class=\"aligncenter\" title=\"\u4f7f\u7528 Bash \u5236\u4f5c Web \u5b89\u5168\u989c\u8272\u63d2\u56fe\" alt=\"\u4f7f\u7528 Bash \u5236\u4f5c Web \u5b89\u5168\u989c\u8272\u63d2\u56fe\" \/><\/p>\n<p>\u5f53\u8ba1\u7b97\u673a\u663e\u793a\u5668\u7684\u8c03\u8272\u677f\u6709\u9650\u65f6\uff0c\u7f51\u9875\u8bbe\u8ba1\u5e08\u901a\u5e38\u4f7f\u7528\u4e00\u7ec4&nbsp;web \u5b89\u5168\u989c\u8272&nbsp;\u6765\u521b\u5efa\u7f51\u7ad9\u3002\u867d\u7136\u5728\u8f83\u65b0\u8bbe\u5907\u4e0a\u663e\u793a\u7684\u73b0\u4ee3\u7f51\u7ad9\u53ef\u4ee5\u663e\u793a\u6bd4\u6700\u521d\u7684 web \u5b89\u5168\u8c03\u8272\u677f\u66f4\u591a\u7684\u989c\u8272\uff0c\u4f46\u6211\u6709\u65f6\u559c\u6b22\u5728\u521b\u5efa\u7f51\u9875\u65f6\u53c2\u8003 web \u5b89\u5168\u989c\u8272\u3002\u8fd9\u6837\u6211\u5c31\u77e5\u9053\u6211\u7684\u7f51\u9875\u5728\u4efb\u4f55\u5730\u65b9\u90fd\u770b\u8d77\u6765\u4e0d\u9519\u3002<\/p>\n<p>\u4f60\u53ef\u4ee5\u5728\u7f51\u4e0a\u627e\u5230 Web \u5b89\u5168\u8c03\u8272\u677f\uff0c\u4f46\u6211\u60f3\u62e5\u6709\u81ea\u5df1\u7684\u526f\u672c\u4ee5\u65b9\u4fbf\u53c2\u8003\u3002\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528 Bash \u4e2d\u7684&nbsp;for&nbsp;\u5faa\u73af\u521b\u5efa\u4e00\u4e2a\u3002<\/p>\n<h3>Bash for \u5faa\u73af<\/h3>\n<p>Bash \u4e2d\u7684 for \u5faa\u73af&nbsp;\u7684\u8bed\u6cd5\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>for \u53d8\u91cf in \u96c6\u5408 ; do \u8bed\u53e5 ; done<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4f8b\u5982\uff0c\u5047\u8bbe\u4f60\u60f3\u6253\u5370\u4ece 1 \u5230 3 \u7684\u6240\u6709\u6570\u5b57\u3002\u4f60\u53ef\u4ee5\u5feb\u901f\u5728 Bash \u547d\u4ee4\u884c\u4e0a\u7f16\u5199\u4e00\u4e2a&nbsp;for&nbsp;\u5faa\u73af\u6765\u4e3a\u4f60\u5b8c\u6210\u8fd9\u9879\u5de5\u4f5c\uff1a<\/p>\n<pre>$ for n in 1 2 3 ; do echo $n ; done123<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5206\u53f7\u662f\u6807\u51c6\u7684 Bash \u8bed\u53e5\u5206\u9694\u7b26\u3002\u5b83\u4eec\u5141\u8bb8\u4f60\u5728\u4e00\u884c\u4e2d\u7f16\u5199\u591a\u4e2a\u547d\u4ee4\u3002\u5982\u679c\u4f60\u8981\u5728 Bash \u811a\u672c\u6587\u4ef6\u4e2d\u5305\u542b\u8fd9\u4e2a&nbsp;for&nbsp;\u5faa\u73af\uff0c\u4f60\u53ef\u4ee5\u7528\u6362\u884c\u7b26\u66ff\u6362\u5206\u53f7\u5e76\u50cf\u8fd9\u6837\u5199\u51fa&nbsp;for&nbsp;\u5faa\u73af\uff1a<\/p>\n<pre>for n in 1 2 3doecho $ndone<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u6211\u559c\u6b22\u5c06&nbsp;do&nbsp;\u548c&nbsp;for&nbsp;\u653e\u5728\u540c\u4e00\u884c\uff0c\u8fd9\u6837\u6211\u66f4\u5bb9\u6613\u9605\u8bfb\uff1a<\/p>\n<pre>for n in 1 2 3 ; doecho $ndone<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<h3>\u4e00\u6b21\u591a\u4e2a for \u5faa\u73af<\/h3>\n<p>\u4f60\u53ef\u4ee5\u5c06\u4e00\u4e2a\u5faa\u73af\u653e\u5728\u53e6\u4e00\u4e2a\u5faa\u73af\u4e2d\u3002\u8fd9\u53ef\u4ee5\u5e2e\u52a9\u4f60\u8fed\u4ee3\u591a\u4e2a\u53d8\u91cf\uff0c\u4e00\u6b21\u505a\u4e0d\u6b62\u4e00\u4ef6\u4e8b\u3002\u5047\u8bbe\u4f60\u60f3\u6253\u5370\u51fa\u5b57\u6bcd A\u3001B \u548c C \u4e0e\u6570\u5b57 1\u30012 \u548c 3 \u7684\u6240\u6709\u7ec4\u5408\u3002\u4f60\u53ef\u4ee5\u5728 Bash \u4e2d\u4f7f\u7528\u4e24\u4e2a&nbsp;for&nbsp;\u5faa\u73af\u6765\u5b9e\u73b0\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>#!\/bin\/bashfor number in 1 2 3 ; dofor letter in A B C ; doecho $letter$numberdonedone<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5982\u679c\u5c06\u8fd9\u4e9b\u884c\u653e\u5728\u540d\u4e3a&nbsp;for.bash&nbsp;\u7684 Bash \u811a\u672c\u6587\u4ef6\u4e2d\u5e76\u8fd0\u884c\u5b83\uff0c\u4f60\u4f1a\u770b\u5230\u4e5d\u884c\u663e\u793a\u4e86\u6240\u6709\u5b57\u6bcd\u4e0e\u6bcf\u4e2a\u6570\u5b57\u914d\u5bf9\u7684\u7ec4\u5408\uff1a<\/p>\n<pre>$ bash for.bashA1B1C1A2B2C2A3B3C3<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<h3>\u904d\u5386 Web \u5b89\u5168\u989c\u8272<\/h3>\n<p>Web \u5b89\u5168\u989c\u8272\u662f\u4ece\u5341\u516d\u8fdb\u5236\u989c\u8272&nbsp;#000\uff08\u9ed1\u8272\uff0c\u5373\u7ea2\u8272\u3001\u7eff\u8272\u548c\u84dd\u8272\u503c\u5747\u4e3a\u96f6\uff09\u5230&nbsp;#fff\uff08\u767d\u8272\uff0c\u5373\u7ea2\u8272\u3001\u7eff\u8272\u548c\u84dd\u8272\u5747\u4e3a\u6700\u9ad8\uff09\uff0c\u6bcf\u4e2a\u5341\u516d\u8fdb\u5236\u503c\u7684\u6b65\u8fdb\u4e3a 0\u30013\u30016\u30019\u3001c \u548c f\u3002<\/p>\n<p>\u4f60\u53ef\u4ee5\u5728 Bash \u4e2d\u4f7f\u7528\u4e09\u4e2a&nbsp;for&nbsp;\u5faa\u73af\u751f\u6210 Web \u5b89\u5168\u989c\u8272\u7684\u6240\u6709\u7ec4\u5408\u7684\u5217\u8868\uff0c\u5176\u4e2d\u5faa\u73af\u904d\u5386\u7ea2\u8272\u3001\u7eff\u8272\u548c\u84dd\u8272\u503c\u3002<\/p>\n<pre>#!\/bin\/bashfor r in 0 3 6 9 c f ; dofor g in 0 3 6 9 c f ; dofor b in 0 3 6 9 c f ; doecho \"#$r$g$b\"donedonedone<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5982\u679c\u5c06\u5176\u4fdd\u5b58\u5728\u540d\u4e3a&nbsp;websafe.bash&nbsp;\u7684\u65b0 Bash \u811a\u672c\u4e2d\u5e76\u8fd0\u884c\u5b83\uff0c\u4f60\u5c31\u4f1a\u770b\u5230\u6240\u6709 Web \u5b89\u5168\u989c\u8272\u7684\u5341\u516d\u8fdb\u5236\u503c\u7684\u8fed\u4ee3\uff1a<\/p>\n<pre>$ bash websafe.bash | head#000#003#006#009#00c#00f#030#033#036#039<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8981\u5236\u4f5c\u53ef\u7528\u4f5c Web \u5b89\u5168\u989c\u8272\u53c2\u8003\u7684 HTML \u9875\u9762\uff0c\u4f60\u9700\u8981\u4f7f\u6bcf\u4e2a\u6761\u76ee\u6210\u4e3a\u4e00\u4e2a\u5355\u72ec\u7684 HTML \u5143\u7d20\u3002\u5c06\u6bcf\u79cd\u989c\u8272\u653e\u5728\u4e00\u4e2a&nbsp;<\/p>\n<p>  &nbsp;\u5143\u7d20\u4e2d\uff0c\u5e76\u5c06\u80cc\u666f\u8bbe\u7f6e\u4e3a Web \u5b89\u5168\u989c\u8272\u3002\u4e3a\u4e86\u4f7f\u5341\u516d\u8fdb\u5236\u503c\u66f4\u6613\u4e8e\u9605\u8bfb\uff0c\u5c06\u5176\u653e\u5728\u5355\u72ec\u7684&nbsp;<br \/>\n<code>&nbsp;\u5143\u7d20\u4e2d\u3002\u5c06 Bash \u811a\u672c\u66f4\u65b0\u4e3a\u5982\u4e0b\uff1a&lt;div class=\"code\" style=\"position:relative; padding:0px; margin:0px;\"&gt;&lt;pre class=\"brush:php;toolbar:false\"&gt;#!\/bin\/bashfor r in 0 3 6 9 c f ; dofor g in 0 3 6 9 c f ; dofor b in 0 3 6 9 c f ; doecho &amp;quot;&amp;lt;div style=&amp;quot;background-color:#$r$g$b&amp;quot;&amp;gt;&amp;lt;code&amp;gt;#$r$g$b&amp;lt;\/code&amp;gt;&amp;lt;\/div&amp;gt;&amp;quot;donedonedone&lt;\/pre&gt;&lt;div class=\"contentsignin\"&gt;\u767b\u5f55\u540e\u590d\u5236&lt;\/div&gt;&lt;\/div&gt; &lt;p&gt;\u5f53\u4f60\u8fd0\u884c\u65b0\u7684 Bash \u811a\u672c\u5e76\u5c06\u7ed3\u679c\u4fdd\u5b58\u5230 HTML \u6587\u4ef6\u65f6\uff0c\u4f60\u53ef\u4ee5\u5728\u6d4f\u89c8\u5668\u4e2d\u67e5\u770b\u6240\u6709 Web \u5b89\u5168\u989c\u8272\u7684\u8f93\u51fa\uff1a&lt;\/p&gt; &lt;div class=\"code\" style=\"position:relative; padding:0px; margin:0px;\"&gt;&lt;pre class=\"brush:php;toolbar:false\"&gt;$ bash websafe.bash &amp;amp;gt; websafe.html&lt;\/pre&gt;&lt;div class=\"contentsignin\"&gt;\u767b\u5f55\u540e\u590d\u5236&lt;\/div&gt;&lt;\/div&gt; &lt;p style=\"text-align:center;\"&gt;&lt;img src=\"https:\/\/img.php.cn\/upload\/article\/000\/887\/227\/168872725169624.jpg\" alt=\"\u4f7f\u7528 Bash \u5236\u4f5c Web \u5b89\u5168\u989c\u8272\"&gt;&lt;\/p&gt; &lt;p&gt;&lt;em&gt;Colour gradient.&lt;\/em&gt;&lt;\/p&gt; &lt;p&gt;\u8fd9\u4e2a\u7f51\u9875\u4e0d\u662f\u5f88\u597d\u770b\u3002\u6df1\u8272\u80cc\u666f\u4e0a\u7684\u9ed1\u8272\u6587\u5b57\u65e0\u6cd5\u9605\u8bfb\u3002\u6211\u559c\u6b22\u4f7f\u7528HTML\u6837\u5f0f\uff0c\u4ee5\u786e\u4fdd\u5728\u989c\u8272\u77e9\u5f62\u4e0a\u4ee5\u767d\u8272\u6587\u672c\u663e\u793a\u5341\u516d\u8fdb\u5236\u503c\uff0c\u5e76\u4e14\u80cc\u666f\u4e3a\u9ed1\u8272\u3002\u6211\u4f7f\u7528\u4e86HTML\u7f51\u683c\u6837\u5f0f\u5c06\u6bcf\u884c\u516d\u4e2a\u6846\u8fdb\u884c\u6392\u5217\uff0c\u5e76\u4e3a\u4e86\u7f8e\u89c2\u6548\u679c\uff0c\u5728\u6846\u4e4b\u95f4\u7559\u6709\u9002\u5f53\u7684\u95f4\u8ddd\u3002&lt;\/p&gt; &lt;p&gt;\u4f60\u9700\u8981\u5728\u5faa\u73af\u4e4b\u524d\u548c\u4e4b\u540e\u5305\u542b\u5176\u4ed6\u7684HTML\u5143\u7d20\u6765\u6dfb\u52a0\u989d\u5916\u7684\u6837\u5f0f\u3002\u5728\u9876\u90e8\u7684HTML\u4ee3\u7801\u4e2d\u5b9a\u4e49\u6837\u5f0f\uff0c\u5e76\u5728\u5e95\u90e8\u7684HTML\u4ee3\u7801\u4e2d\u5173\u95ed\u6240\u6709\u5df2\u6253\u5f00\u7684HTML\u6807\u7b7e&lt;\/p&gt; &lt;div class=\"code\" style=\"position:relative; padding:0px; margin:0px;\"&gt;&lt;pre class=\"brush:php;toolbar:false\"&gt;#!\/bin\/bashcat&amp;lt;title&amp;gt;Web-safe colors&amp;lt;\/title&amp;gt;&amp;lt;meta name=&amp;quot;viewport&amp;quot; content=&amp;quot;width=device-width, initial-scale=1&amp;quot;&amp;gt;&amp;lt;style&amp;gt;div {padding-bottom: 1em;}code {background-color: black;color: white;}@media only screen and (min-width:600px) {body {display: grid;grid-template-columns: repeat(6,1fr);column-gap: 1em;row-gap: 1em;}div {padding-bottom: 3em;}}&amp;lt;\/style&amp;gt;EOFfor r in 0 3 6 9 c f ; dofor g in 0 3 6 9 c f ; dofor b in 0 3 6 9 c f ; doecho &amp;quot;&amp;lt;divstyle&amp;gt;&amp;lt;code&amp;gt;#$r$g$b&amp;lt;\/code&amp;gt;&amp;lt;\/divstyle&amp;gt;&lt;\/pre&gt;&lt;div class=\"contentsignin\"&gt;\u767b\u5f55\u540e\u590d\u5236&lt;\/div&gt;&lt;\/div&gt;<\/code> &#8220;donedonedonecat <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u4f7f\u7528 Bash \u5236\u4f5c Web \u5b89\u5168\u989c\u8272\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8FDCServers\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f53\u8ba1\u7b97\u673a\u663e\u793a\u5668\u7684\u8c03\u8272\u677f\u6709\u9650\u65f6\uff0c\u7f51\u9875\u8bbe\u8ba1\u5e08\u901a\u5e38\u4f7f\u7528\u4e00\u7ec4&nbsp;web \u5b89\u5168\u989c\u8272&nbsp;\u6765\u521b\u5efa\u7f51\u7ad9\u3002\u867d\u7136\u5728\u8f83\u65b0\u8bbe\u5907\u4e0a\u663e\u793a\u7684\u73b0\u4ee3\u7f51\u7ad9\u53ef\u4ee5\u663e\u793a\u6bd4\u6700\u521d\u7684 web \u5b89\u5168\u8c03\u8272\u677f\u66f4\u591a\u7684\u989c\u8272\uff0c\u4f46\u6211\u6709\u65f6\u559c\u6b22\u5728\u521b\u5efa\u7f51\u9875\u65f6\u53c2\u8003 web \u5b89\u5168\u989c\u8272\u3002\u8fd9\u6837\u6211\u5c31\u77e5\u9053\u6211\u7684\u7f51\u9875\u5728\u4efb\u4f55\u5730\u65b9\u90fd\u770b\u8d77\u6765\u4e0d\u9519\u3002 \u4f60\u53ef\u4ee5\u5728\u7f51\u4e0a\u627e\u5230 Web \u5b89\u5168\u8c03\u8272\u677f\uff0c\u4f46\u6211\u60f3\u62e5\u6709\u81ea\u5df1\u7684\u526f\u672c\u4ee5\u65b9\u4fbf\u53c2\u8003\u3002\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528 Bash \u4e2d\u7684&nbsp;for&nbsp;\u5faa\u73af\u521b\u5efa\u4e00\u4e2a\u3002 Bash for \u5faa\u73af Bash \u4e2d\u7684 for \u5faa\u73af&nbsp;\u7684\u8bed\u6cd5\u5982\u4e0b\u6240\u793a\uff1a for \u53d8\u91cf in \u96c6\u5408 ; do \u8bed\u53e5 ; done \u767b\u5f55\u540e\u590d\u5236 \u4f8b\u5982\uff0c\u5047\u8bbe\u4f60\u60f3\u6253\u5370\u4ece 1 \u5230 3 \u7684\u6240\u6709\u6570\u5b57\u3002\u4f60\u53ef\u4ee5\u5feb\u901f\u5728 Bash \u547d\u4ee4\u884c\u4e0a\u7f16\u5199\u4e00\u4e2a&nbsp;for&nbsp;\u5faa\u73af\u6765\u4e3a\u4f60\u5b8c\u6210\u8fd9\u9879\u5de5\u4f5c\uff1a $ for n in 1 2 3 ; do echo $n ; done123 \u767b\u5f55\u540e\u590d\u5236 \u5206\u53f7\u662f\u6807\u51c6\u7684 Bash \u8bed\u53e5\u5206\u9694\u7b26\u3002\u5b83\u4eec\u5141\u8bb8\u4f60\u5728\u4e00\u884c\u4e2d\u7f16\u5199\u591a\u4e2a\u547d\u4ee4\u3002\u5982\u679c\u4f60\u8981\u5728 Bash \u811a\u672c\u6587\u4ef6\u4e2d\u5305\u542b\u8fd9\u4e2a&nbsp;for&nbsp;\u5faa\u73af\uff0c\u4f60\u53ef\u4ee5\u7528\u6362\u884c\u7b26\u66ff\u6362\u5206\u53f7\u5e76\u50cf\u8fd9\u6837\u5199\u51fa&nbsp;for&nbsp;\u5faa\u73af\uff1a for [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-61714","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/61714","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=61714"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/61714\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=61714"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=61714"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=61714"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}