歡迎光臨
每天分享高質量文章

一個轉換花引號的 gawk 指令碼 | Linux 中國

得到我的 awk 秘籍。
— Jim Hall


致謝
編譯自 | 
https://opensource.com/article/18/8/gawk-script-convert-smart-quotes
 
 作者 | Jim Hall
 譯者 | DarkSun (lujun9972) ?????共計翻譯:81 篇 貢獻時間:277 天

得到我的 awk 秘籍。

我管理著一個個人網站,用手工編輯網站上的網頁。由於網站上的頁面並不多,這種方法對我很適合,可以讓我對網站程式碼的細節一清二楚。

最近我升級了網站的設計樣式,我決定把所有的普通引號都轉換成“花引號”,即在列印材料中使用的那種引號:用 “” 來代替 “”。

手工修改所有的引號太耗時了,因此我決定將這個轉換所有 HTML 檔案中引號的過程自動化。不過透過程式或指令碼來實現該功能需要費點勁。這個指令碼需要知道何時將普通引號轉換成花引號,並決定使用哪種引號(LCTT 譯註:左引號還是右引號,單引號還是雙引號)。

有多種方法可以轉換引號。Greg Pittman 寫過一個 Python 指令碼[1] 來修正文字中的花引號。而我自己使用 GNU awk[2] (gawk) 來實現。

下載我的 awk 秘籍。免費下載[2]

開始之前,我寫了一個簡單的 gawk 函式來評估單個字元。若該字元是一個引號,這該函式判斷是輸出普通引號還是花引號。函式檢視前一個字元;若前一個字元是空格,則函式輸出左花引號。否則函式輸出右花引號。指令碼對單引號的處理方式也一樣。

  1. function smartquote (char, prevchar) {

  2.         # print smart quotes depending on the previous character

  3.         # otherwise just print the character as-is

  4.         if (prevchar ~ /\s/) {

  5.                 # prev char is a space

  6.                 if (char == "'") {

  7.                         printf("‘");

  8.                 }

  9.                 else if (char == "\"") {

  10.                         printf("“");

  11.                 }

  12.                 else {

  13.                         printf("%c", char);

  14.                 }

  15.         }

  16.         else {

  17.                 # prev char is not a space

  18.                 if (char == "'") {

  19.                         printf("’");

  20.                 }

  21.                 else if (char == "\"") {

  22.                         printf("”");

  23.                 }

  24.                 else {

  25.                         printf("%c", char);

  26.                 }

  27.         }

  28. }

這個 gawk 指令碼的主體部分透過該函式處理 HTML 輸入檔案的一個個字元。該指令碼在 HTML 標簽內部逐字原樣輸出所有內容(比如,)。在 HTML 標簽外,指令碼使用 smartquote() 函式來輸出文本。smartquote() 函式來評估是輸出普通引號還是花引號。

  1. function smartquote (char, prevchar) {

  2.         ...

  3. }

  4. BEGIN {htmltag = 0}

  5. {

  6.         # for each line, scan one letter at a time:

  7.         linelen = length($0);

  8.         prev = "\n";

  9.         for (i = 1; i <= linelen; i++) {

  10.                 char = substr($0, i, 1);

  11.                 if (char == ") {

  12.                         htmltag = 1;

  13.                 }

  14.                 if (htmltag == 1) {

  15.                         printf("%c", char);

  16.                 }

  17.                 else {

  18.                         smartquote(char, prev);

  19.                         prev = char;

  20.                 }

  21.                 if (char == ">") {

  22.                         htmltag = 0;

  23.                 }

  24.         }

  25.         # add trailing newline at end of each line

  26.         printf ("\n");

  27. }

下麵是一個例子:

  1. gawk -f quotes.awk test.html > test2.html

其輸入為:

  1. lang="en">

  2.   </span><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);">Test page</span><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);"/></code></p></li></ol></pre> </section> <li> <p><code style="word-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);">  </span><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);"><link/><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="atn" style="word-wrap: break-word;color: rgb(189, 183, 107);">rel</span><span class="pun" style="word-wrap: break-word;color: rgb(184, 255, 184);">=</span><span class="atv" style="word-wrap: break-word;color: rgb(101, 176, 66);">"stylesheet"</span><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="atn" style="word-wrap: break-word;color: rgb(189, 183, 107);">type</span><span class="pun" style="word-wrap: break-word;color: rgb(184, 255, 184);">=</span><span class="atv" style="word-wrap: break-word;color: rgb(101, 176, 66);">"text/css"</span><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="atn" style="word-wrap: break-word;color: rgb(189, 183, 107);">href</span><span class="pun" style="word-wrap: break-word;color: rgb(184, 255, 184);">=</span><span class="atv" style="word-wrap: break-word;color: rgb(101, 176, 66);">"/test.css"</span><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);">/></span></span></code></p> </li> <li> <p><code style="word-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);">  </span><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);"><meta/><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="atn" style="word-wrap: break-word;color: rgb(189, 183, 107);">charset</span><span class="pun" style="word-wrap: break-word;color: rgb(184, 255, 184);">=</span><span class="atv" style="word-wrap: break-word;color: rgb(101, 176, 66);">"UTF-8"</span><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);">></span></span></code></p> </li> <li> <p><code style="word-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);">  </span><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);"><meta/><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="atn" style="word-wrap: break-word;color: rgb(189, 183, 107);">name</span><span class="pun" style="word-wrap: break-word;color: rgb(184, 255, 184);">=</span><span class="atv" style="word-wrap: break-word;color: rgb(101, 176, 66);">"viewport"</span><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="atn" style="word-wrap: break-word;color: rgb(189, 183, 107);">content</span><span class="pun" style="word-wrap: break-word;color: rgb(184, 255, 184);">=</span><span class="atv" style="word-wrap: break-word;color: rgb(101, 176, 66);">"width=device-width"</span><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);">/></span></span></code></p> </li> <li> <p><code style="word-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);"/></code></p> </li> <li> <p><code style="word-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);"/></code></p> </li> <li> <p><code style="word-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);">  </span><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);"></p> <h1><a/></h1> <p></span><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="atn" style="word-wrap: break-word;color: rgb(189, 183, 107);">href</span><span class="pun" style="word-wrap: break-word;color: rgb(184, 255, 184);">=</span><span class="atv" style="word-wrap: break-word;color: rgb(101, 176, 66);">"/"</span><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);">><img/><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="atn" style="word-wrap: break-word;color: rgb(189, 183, 107);">src</span><span class="pun" style="word-wrap: break-word;color: rgb(184, 255, 184);">=</span><span class="atv" style="word-wrap: break-word;color: rgb(101, 176, 66);">"logo.png"</span><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="atn" style="word-wrap: break-word;color: rgb(189, 183, 107);">alt</span><span class="pun" style="word-wrap: break-word;color: rgb(184, 255, 184);">=</span><span class="atv" style="word-wrap: break-word;color: rgb(101, 176, 66);">"Website logo"</span><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);">/></span></span></code></p> </li> <li> <p><code style="word-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);">  </span><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);"></p> <p/></span><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);">"Hi there!"</span><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);"/></code></p> </li> <li> <p><code style="word-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);">  </span><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);"></p> <p/></span><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);">It's and its.</span><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);"/></code></p> </li> <li> <p><code style="word-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);"/></code></p> </li> <li> <p><code style="word-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);"/></code></p> </li> <p style="word-wrap: break-word;margin-top: 1.5em;margin-bottom: 1.5em;line-height: 2em;">其輸出為:</p> <pre class="prettyprint linenums prettyprinted" style="word-wrap: break-word;background-color: rgb(22, 27, 32);background-image: none;box-shadow: rgba(0, 0, 0, 0.5) 0px 0px 5px;text-shadow: rgb(0, 0, 0) 0px 1px 1px;border-radius: 6px;color: rgb(184, 255, 184);margin: 10px;padding: 1em 1em 1em 0px;white-space: pre-wrap;border-width: 1px;border-style: solid;border-color: rgb(0, 0, 0);line-height: 1.2em;letter-spacing: 0px !important;"><ol class="linenums list-paddingleft-2" style="margin-left: 2em;margin-right: 2em;"><li><p><code style="word-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="dec" style="word-wrap: break-word;color: rgb(51, 135, 204);"> </span></code></p></li><li><p><code style="word-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);"><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="atn" style="word-wrap: break-word;color: rgb(189, 183, 107);">lang</span><span class="pun" style="word-wrap: break-word;color: rgb(184, 255, 184);">=</span><span class="atv" style="word-wrap: break-word;color: rgb(101, 176, 66);">"en"</span><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);">></span></span></code></p></li><li><p><code style="word-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);"/></code></p></li><li><p><code style="word-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);">  </span><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);"><title/></span><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);">Test page</span><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);"/></code></p></li></ol></pre> <li> <p><code style="word-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);">  </span><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);"><link/><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="atn" style="word-wrap: break-word;color: rgb(189, 183, 107);">rel</span><span class="pun" style="word-wrap: break-word;color: rgb(184, 255, 184);">=</span><span class="atv" style="word-wrap: break-word;color: rgb(101, 176, 66);">"stylesheet"</span><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="atn" style="word-wrap: break-word;color: rgb(189, 183, 107);">type</span><span class="pun" style="word-wrap: break-word;color: rgb(184, 255, 184);">=</span><span class="atv" style="word-wrap: break-word;color: rgb(101, 176, 66);">"text/css"</span><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="atn" style="word-wrap: break-word;color: rgb(189, 183, 107);">href</span><span class="pun" style="word-wrap: break-word;color: rgb(184, 255, 184);">=</span><span class="atv" style="word-wrap: break-word;color: rgb(101, 176, 66);">"/test.css"</span><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);">/></span></span></code></p> </li> <li> <p><code style="word-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);">  </span><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);"><meta/><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="atn" style="word-wrap: break-word;color: rgb(189, 183, 107);">charset</span><span class="pun" style="word-wrap: break-word;color: rgb(184, 255, 184);">=</span><span class="atv" style="word-wrap: break-word;color: rgb(101, 176, 66);">"UTF-8"</span><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);">></span></span></code></p> </li> <li> <p><code style="word-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);">  </span><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);"><meta/><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="atn" style="word-wrap: break-word;color: rgb(189, 183, 107);">name</span><span class="pun" style="word-wrap: break-word;color: rgb(184, 255, 184);">=</span><span class="atv" style="word-wrap: break-word;color: rgb(101, 176, 66);">"viewport"</span><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="atn" style="word-wrap: break-word;color: rgb(189, 183, 107);">content</span><span class="pun" style="word-wrap: break-word;color: rgb(184, 255, 184);">=</span><span class="atv" style="word-wrap: break-word;color: rgb(101, 176, 66);">"width=device-width"</span><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);">/></span></span></code></p> </li> <li> <p><code style="word-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);"/></code></p> </li> <li> <p><code style="word-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);"/></code></p> </li> <li> <p><code style="word-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);">  </span><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);"></p> <h1><a/></h1> <p></span><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="atn" style="word-wrap: break-word;color: rgb(189, 183, 107);">href</span><span class="pun" style="word-wrap: break-word;color: rgb(184, 255, 184);">=</span><span class="atv" style="word-wrap: break-word;color: rgb(101, 176, 66);">"/"</span><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);">><img/><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="atn" style="word-wrap: break-word;color: rgb(189, 183, 107);">src</span><span class="pun" style="word-wrap: break-word;color: rgb(184, 255, 184);">=</span><span class="atv" style="word-wrap: break-word;color: rgb(101, 176, 66);">"logo.png"</span><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="atn" style="word-wrap: break-word;color: rgb(189, 183, 107);">alt</span><span class="pun" style="word-wrap: break-word;color: rgb(184, 255, 184);">=</span><span class="atv" style="word-wrap: break-word;color: rgb(101, 176, 66);">"Website logo"</span><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);">/></span></span></code></p> </li> <li> <p><code style="word-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);">  </span><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);"></p> <p/></span><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);">“Hi there!”</span><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);"/></code></p> </li> <li> <p><code style="word-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);">  </span><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);"></p> <p/></span><span class="pln" style="word-wrap: break-word;color: rgb(184, 255, 184);">It’s and its.</span><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);"/></code></p> </li> <li> <p><code style="word-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);"/></code></p> </li> <li> <p><code style="word-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="tag" style="word-wrap: break-word;color: rgb(137, 189, 255);"/></code></p> </li> <hr style="word-wrap: break-word;clear: both;margin-right: 10px;margin-left: 10px;"/> <p style="word-wrap: break-word;margin-top: 1.5em;margin-bottom: 1.5em;line-height: 2em;">via: <span style="word-wrap: break-word;color: rgb(77, 138, 216);">https://opensource.com/article/18/8/gawk-script-convert-smart-quotes</span></p> <p style="word-wrap: break-word;margin-top: 1.5em;margin-bottom: 1.5em;line-height: 2em;">作者:<span style="word-wrap: break-word;color: rgb(77, 138, 216);">Jim Hall</span><span class="sup" style="word-wrap: break-word;font-size: 9px;vertical-align: super;background-color: rgb(102, 102, 102);color: rgb(255, 255, 255);transform: scale(0.75);display: inline-block;padding: 1px;line-height: 1em;">[4]</span> 選題:<span style="word-wrap: break-word;color: rgb(77, 138, 216);">lujun9972</span> 譯者:<span style="word-wrap: break-word;color: rgb(77, 138, 216);">lujun9972</span> 校對:<span style="word-wrap: break-word;color: rgb(77, 138, 216);">wxy</span></p> <p style="word-wrap: break-word;margin-top: 1.5em;margin-bottom: 1.5em;line-height: 2em;">本文由 <span style="word-wrap: break-word;color: rgb(77, 138, 216);">LCTT</span> 原創編譯,<span style="word-wrap: break-word;color: rgb(77, 138, 216);">Linux中國</span> 榮譽推出</p> <p></p> <div class="ct_mpda_wrp" id="js_sponsor_ad_area" style="display:none;"/> <div class="reward_qrcode_area reward_area tc" id="js_reward_qrcode" style="display:none;"> <p class="tips_global">長按二維碼向我轉賬</p> <p class="reward_tips"/> <span class="reward_qrcode_img_wrp"><img class="reward_qrcode_img" id="js_reward_qrcode_img"/></span></p> <p class="tips_global">受蘋果公司新規定影響,微信 iOS 版的贊賞功能被關閉,可透過二維碼轉賬支援公眾號。</p> </div> <ul class="article_extend_area" id="js_hotspot_area"/> <div class="rich_media_tool" id="js_toobar3"> <a class="media_tool_meta meta_primary" csmlink="8vge3c" href="http://chuansongme.com/r/8vge3c" id="js_view_source" rel="nofollow" target="_blank">閱讀原文</a></p> </div> <div class="weui-desktop-popover weui-desktop-popover_pos-up-center weui-desktop-popover_img-text" id="js_pc_weapp_code" style="display: none;"> <div class="weui-desktop-popover__content"> <div class="weui-desktop-popover__desc"> <img id="js_pc_weapp_code_img"/><br /> 微信掃一掃<br />使用小程式<span id="js_pc_weapp_code_des"/> </div> </div> </div> <div id="js_minipro_dialog" style="display:none;"> <div class="weui-mask"/> <div class="weui-dialog"> <div class="weui-dialog__bd">即將開啟"<span id="js_minipro_dialog_name"/>"小程式</div> <div class="weui-dialog__ft"> <a class="weui-dialog__btn weui-dialog__btn_default" href="javascript:void(0);" id="js_minipro_dialog_cancel">取消</a><br /> <a class="weui-dialog__btn weui-dialog__btn_primary" href="javascript:void(0);" id="js_minipro_dialog_ok">開啟</a> </div> </div> </div> </div> </article> <div class="post-actions"> <a href="javascript:;" class="post-like action action-like" data-pid="5582"><i class="fa fa-thumbs-o-up"></i>贊(<span>0</span>)</a> </div> <div class="action-share"></div> <div class="article-tags">標籤:<a href="http://www.ipshop.xyz/tag/ios" rel="tag">iOS</a><a href="http://www.ipshop.xyz/tag/linux" rel="tag">Linux</a><a href="http://www.ipshop.xyz/tag/python" rel="tag">Python</a></div> <nav class="article-nav"> <span class="article-nav-prev">上一篇<br><a href="http://www.ipshop.xyz/5581.html" rel="prev">適用於 Fedora 28 的 3 款酷炫生產力應用 | Linux 中國</a></span> <span class="article-nav-next">下一篇<br><a href="http://www.ipshop.xyz/5583.html" rel="next">【每日安全資訊】這下好了,家裡的智慧燈泡都會洩露資料了</a></span> </nav> <div class="relates"><div class="title"><h3>相關推薦</h3></div><ul><li><a href="http://www.ipshop.xyz/18679.html">PyQt5 執行緒管理 解決耗時執行緒導致假死問題</a></li><li><a href="http://www.ipshop.xyz/18292.html">分庫分表實戰:可能是使用者表最佳分庫分表方案</a></li><li><a href="http://www.ipshop.xyz/18291.html">4 張 GIF 圖幫助你理解二叉搜尋樹</a></li><li><a href="http://www.ipshop.xyz/17827.html">分散式鏈路追蹤 SkyWalking 原始碼分析 —— Agent 收集 Trace 資料</a></li><li><a href="http://www.ipshop.xyz/17784.html">一份來自英偉達的越南小姐姐整理的機器學習入門清單,照這樣學就對了</a></li><li><a href="http://www.ipshop.xyz/17854.html">HBase 資料遷移方案介紹</a></li><li><a href="http://www.ipshop.xyz/17853.html">C# 管道式程式設計</a></li><li><a href="http://www.ipshop.xyz/17787.html">不會SQL註入,連漫畫都看不懂了</a></li></ul></div> </div> </div> <div class="sidebar"> <div class="widget widget_ui_asb"><div class="item"><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- ad3 --> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-3715363832600463" data-ad-slot="8216000168" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script></div></div><div class="widget widget_ui_tags"><h3>熱門標籤</h3><div class="items"><a href="http://www.ipshop.xyz/tag/ios">iOS (11238)</a><a href="http://www.ipshop.xyz/tag/%e5%be%ae%e8%bb%9f">微軟 (4955)</a><a href="http://www.ipshop.xyz/tag/linux">Linux (4274)</a><a href="http://www.ipshop.xyz/tag/%e5%ae%89%e5%85%a8">安全 (4180)</a><a href="http://www.ipshop.xyz/tag/python">Python (4161)</a><a href="http://www.ipshop.xyz/tag/%e6%80%a7%e8%83%bd">效能 (3165)</a><a href="http://www.ipshop.xyz/tag/%e9%81%8b%e7%b6%ad">運維 (2774)</a><a href="http://www.ipshop.xyz/tag/%e5%84%aa%e5%8c%96">最佳化 (2419)</a><a href="http://www.ipshop.xyz/tag/net">.NET (2262)</a><a href="http://www.ipshop.xyz/tag/google">Google (2136)</a><a href="http://www.ipshop.xyz/tag/%e6%a9%9f%e5%99%a8%e5%ad%b8%e7%bf%92">機器學習 (1795)</a><a href="http://www.ipshop.xyz/tag/%e4%bd%b5%e7%99%bc">併發 (1613)</a><a href="http://www.ipshop.xyz/tag/%e5%88%86%e4%bd%88%e5%bc%8f">分散式 (1559)</a><a href="http://www.ipshop.xyz/tag/%e9%9b%86%e7%be%a4">叢集 (1240)</a><a href="http://www.ipshop.xyz/tag/sql">SQL (1174)</a><a href="http://www.ipshop.xyz/tag/mysql">Mysql (1060)</a><a href="http://www.ipshop.xyz/tag/%e5%8d%80%e5%a1%8a%e9%8f%88">區塊鏈 (1017)</a><a href="http://www.ipshop.xyz/tag/docker">Docker (977)</a><a href="http://www.ipshop.xyz/tag/%e5%be%ae%e6%9c%8d%e5%8b%99">微服務 (922)</a><a href="http://www.ipshop.xyz/tag/%e9%9d%a2%e8%a9%a6">面試 (919)</a><a href="http://www.ipshop.xyz/tag/apache">Apache (743)</a><a href="http://www.ipshop.xyz/tag/nlp">NLP (725)</a><a href="http://www.ipshop.xyz/tag/redis">Redis (719)</a><a href="http://www.ipshop.xyz/tag/android">Android (668)</a><a href="http://www.ipshop.xyz/tag/git">Git (640)</a><a href="http://www.ipshop.xyz/tag/%e6%9e%b6%e6%a7%8b%e5%b8%ab">架構師 (632)</a><a href="http://www.ipshop.xyz/tag/nginx">Nginx (630)</a><a href="http://www.ipshop.xyz/tag/facebook">Facebook (599)</a><a href="http://www.ipshop.xyz/tag/jvm">JVM (595)</a><a href="http://www.ipshop.xyz/tag/%e7%88%ac%e8%9f%b2">爬蟲 (476)</a></div></div><div class="widget widget_ui_posts"><h3>熱門文章</h3><ul class="nopic"><li><a href="http://www.ipshop.xyz/15779.html"><span class="text">用 docker-compose 啟動 WebApi 和 SQL Server</span><span class="muted">2019-06-26</span></a></li> <li><a href="http://www.ipshop.xyz/9049.html"><span class="text">電線電纜的平方數及平方數和電流的換算公式</span><span class="muted">2018-04-02</span></a></li> <li><a href="http://www.ipshop.xyz/1250.html"><span class="text">實體 :手把手教你用PyTorch快速準確地建立神經網路(附4個學習用例)</span><span class="muted">2019-02-02</span></a></li> <li><a href="http://www.ipshop.xyz/1208.html"><span class="text">面試官讓用5種python方法實現字串反轉?對不起我有16種……</span><span class="muted">2019-01-13</span></a></li> <li><a href="http://www.ipshop.xyz/12632.html"><span class="text">小樣本學習(Few-shot Learning)綜述</span><span class="muted">2019-04-01</span></a></li> <li><a href="http://www.ipshop.xyz/4542.html"><span class="text">黎曼猜想仍舊,素數依然孤獨</span><span class="muted">2018-09-26</span></a></li> </ul></div></div></section> <div class="branding branding-black"> <div class="container"> <h2>分享創造快樂</h2> </div> </div> <footer class="footer"> <div class="container"> <p>© 2024 <a href="http://www.ipshop.xyz">知識星球</a>   <a href="http://www.ipshop.xyz/sitemap.xml">網站地圖</a> </p> <!-- Global site tag (gtag.js) - Google Analytics --> <script async src="https://www.googletagmanager.com/gtag/js?id=UA-133465382-1"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-133465382-1'); </script> </div> </footer> <script> window.jsui={ www: 'http://www.ipshop.xyz', uri: 'http://www.ipshop.xyz/wp-content/themes/dux', ver: '5.0', roll: [], ajaxpager: '0', url_rp: '', qq_id: '', qq_tip: '' }; </script> <script type='text/javascript' src='http://www.ipshop.xyz/wp-content/themes/dux/js/libs/bootstrap.min.js?ver=5.0' id='bootstrap-js'></script> <script type='text/javascript' src='http://www.ipshop.xyz/wp-content/themes/dux/js/loader.js?ver=5.0' id='_loader-js'></script> </body> </html>