六月丁香五月婷婷,丁香五月婷婷网,欧美激情网站,日本护士xxxx,禁止18岁天天操夜夜操,18岁禁止1000免费,国产福利无码一区色费

學習啦>學習電腦>操作系統(tǒng)>Linux教程>

程序員都應(yīng)該知道什么Linux命令

時間: 春健736 分享

  程序員都應(yīng)該知道什么Linux命令?每個程序員,在職業(yè)生涯的某個時刻,總會發(fā)現(xiàn)自己需要知道一些Linux方面的知識。學習啦小編分享了程序員都應(yīng)該知道的8個Linux命令,希望對大家有所幫助。

  程序員都應(yīng)該知道的8個Linux命令

  我們以一些文本舉例。假設(shè)我們有2個文件,里面有訂單關(guān)于第三方的放置地點和發(fā)送回應(yīng)。

  cat order.out.log

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  cat order.in.log

  8:22:20 111, Order Complete

  8:23:50 112, Order sent to fulfillment

  8:24:20 113, Refund sent to processing

  cat

  –追加文件并在標準輸出上打印

  jfields$ cat order.out.log

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  正如他的名字所說的,你可以串聯(lián)多個文件

  jfields$ cat order.*

  8:22:20 111, Order Complete

  8:23:50 112, Order sent to fulfillment

  8:24:20 113, Refund sent to processing

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  看到效果了,但我們可以提高其可讀性。

  sort

  –對文本文件進行行排序,這里使用排序是不錯的選擇

  jfields$ cat order.* | sort

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:22:20 111, Order Complete

  8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99

  8:23:50 112, Order sent to fulfillment

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:24:20 113, Refund sent to processing

  上面顯示了我們想要看到的效果,但是這只是小文件。而真實的數(shù)據(jù)是很大的,有些是你不想要的數(shù)據(jù)怎么辦?

  grep

  grep, egrep, fgrep–進行匹配輸出

  假設(shè)我只關(guān)心給PofEAA的訂單,使用grep就可以做到。

  jfields$ cat order.* | sort | grep Patterns

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  假設(shè)訂單113里面發(fā)生了一些問題,你想看到關(guān)于113的所有訂單信息。沒錯,grep能幫你。

  jfields$ cat order.* | sort | grep “:\d\d 113, ”

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:24:20 113, Refund sent to processing

  你會發(fā)現(xiàn)在表達式里面不止有113,這是因為113也可能出現(xiàn)在價格里面,或者產(chǎn)品里面,這樣做是嚴格限制其查找結(jié)果。

  現(xiàn)在我們已經(jīng)發(fā)出退貨訂單的信息,我們每日也要給會計發(fā)送銷售統(tǒng)計。他們要求每個PofEAA的項目,但他們只關(guān)心數(shù)量和價格,我們要把

  不需要的部分刪減掉。

  cut

  –從文件的每一行刪除一部分

  還是要先使用grep。

  jfields$ cat order.* | sort | grep Patterns

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  jfields$ cat order.* | sort | grep Patterns | cut -d”,” -f2,5

  1, 39.99

  -1, 39.99

  我們已經(jīng)減少了數(shù)據(jù),讓會計一目了然。

  假設(shè)會計想要把訂單ID做為參考,把它放在每一行的最后,并用單引號。

  sed

  –流編輯器。用來處理文本轉(zhuǎn)換。

  下面的示例演示怎樣使用它來做到我們想要的數(shù)據(jù)。

  jfields$ cat order.* | sort | grep Patterns \

  >| sed s/”[0-9\:]* \([0-9]*\)\, \(.*\)”/”

  程序員都應(yīng)該知道什么Linux命令?每個程序員,在職業(yè)生涯的某個時刻,總會發(fā)現(xiàn)自己需要知道一些Linux方面的知識。學習啦小編分享了程序員都應(yīng)該知道的8個Linux命令,希望對大家有所幫助。

  程序員都應(yīng)該知道的8個Linux命令

  我們以一些文本舉例。假設(shè)我們有2個文件,里面有訂單關(guān)于第三方的放置地點和發(fā)送回應(yīng)。

  cat order.out.log

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  cat order.in.log

  8:22:20 111, Order Complete

  8:23:50 112, Order sent to fulfillment

  8:24:20 113, Refund sent to processing

  cat

  –追加文件并在標準輸出上打印

  jfields$ cat order.out.log

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  正如他的名字所說的,你可以串聯(lián)多個文件

  jfields$ cat order.*

  8:22:20 111, Order Complete

  8:23:50 112, Order sent to fulfillment

  8:24:20 113, Refund sent to processing

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  看到效果了,但我們可以提高其可讀性。

  sort

  –對文本文件進行行排序,這里使用排序是不錯的選擇

  jfields$ cat order.* | sort

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:22:20 111, Order Complete

  8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99

  8:23:50 112, Order sent to fulfillment

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:24:20 113, Refund sent to processing

  上面顯示了我們想要看到的效果,但是這只是小文件。而真實的數(shù)據(jù)是很大的,有些是你不想要的數(shù)據(jù)怎么辦?

  grep

  grep, egrep, fgrep–進行匹配輸出

  假設(shè)我只關(guān)心給PofEAA的訂單,使用grep就可以做到。

  jfields$ cat order.* | sort | grep Patterns

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  假設(shè)訂單113里面發(fā)生了一些問題,你想看到關(guān)于113的所有訂單信息。沒錯,grep能幫你。

  jfields$ cat order.* | sort | grep “:\d\d 113, ”

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:24:20 113, Refund sent to processing

  你會發(fā)現(xiàn)在表達式里面不止有113,這是因為113也可能出現(xiàn)在價格里面,或者產(chǎn)品里面,這樣做是嚴格限制其查找結(jié)果。

  現(xiàn)在我們已經(jīng)發(fā)出退貨訂單的信息,我們每日也要給會計發(fā)送銷售統(tǒng)計。他們要求每個PofEAA的項目,但他們只關(guān)心數(shù)量和價格,我們要把

  不需要的部分刪減掉。

  cut

  –從文件的每一行刪除一部分

  還是要先使用grep。

  jfields$ cat order.* | sort | grep Patterns

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  jfields$ cat order.* | sort | grep Patterns | cut -d”,” -f2,5

  1, 39.99

  -1, 39.99

  我們已經(jīng)減少了數(shù)據(jù),讓會計一目了然。

  假設(shè)會計想要把訂單ID做為參考,把它放在每一行的最后,并用單引號。

  sed

  –流編輯器。用來處理文本轉(zhuǎn)換。

  下面的示例演示怎樣使用它來做到我們想要的數(shù)據(jù)。

  jfields$ cat order.* | sort | grep Patterns \

  >| sed s/”[0-9\:]* \([0-9]*\)\, \(.*\)”/”

  程序員都應(yīng)該知道什么Linux命令?每個程序員,在職業(yè)生涯的某個時刻,總會發(fā)現(xiàn)自己需要知道一些Linux方面的知識。學習啦小編分享了程序員都應(yīng)該知道的8個Linux命令,希望對大家有所幫助。

  程序員都應(yīng)該知道的8個Linux命令

  我們以一些文本舉例。假設(shè)我們有2個文件,里面有訂單關(guān)于第三方的放置地點和發(fā)送回應(yīng)。

  cat order.out.log

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  cat order.in.log

  8:22:20 111, Order Complete

  8:23:50 112, Order sent to fulfillment

  8:24:20 113, Refund sent to processing

  cat

  –追加文件并在標準輸出上打印

  jfields$ cat order.out.log

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  正如他的名字所說的,你可以串聯(lián)多個文件

  jfields$ cat order.*

  8:22:20 111, Order Complete

  8:23:50 112, Order sent to fulfillment

  8:24:20 113, Refund sent to processing

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  看到效果了,但我們可以提高其可讀性。

  sort

  –對文本文件進行行排序,這里使用排序是不錯的選擇

  jfields$ cat order.* | sort

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:22:20 111, Order Complete

  8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99

  8:23:50 112, Order sent to fulfillment

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:24:20 113, Refund sent to processing

  上面顯示了我們想要看到的效果,但是這只是小文件。而真實的數(shù)據(jù)是很大的,有些是你不想要的數(shù)據(jù)怎么辦?

  grep

  grep, egrep, fgrep–進行匹配輸出

  假設(shè)我只關(guān)心給PofEAA的訂單,使用grep就可以做到。

  jfields$ cat order.* | sort | grep Patterns

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  假設(shè)訂單113里面發(fā)生了一些問題,你想看到關(guān)于113的所有訂單信息。沒錯,grep能幫你。

  jfields$ cat order.* | sort | grep “:\d\d 113, ”

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:24:20 113, Refund sent to processing

  你會發(fā)現(xiàn)在表達式里面不止有113,這是因為113也可能出現(xiàn)在價格里面,或者產(chǎn)品里面,這樣做是嚴格限制其查找結(jié)果。

  現(xiàn)在我們已經(jīng)發(fā)出退貨訂單的信息,我們每日也要給會計發(fā)送銷售統(tǒng)計。他們要求每個PofEAA的項目,但他們只關(guān)心數(shù)量和價格,我們要把

  不需要的部分刪減掉。

  cut

  –從文件的每一行刪除一部分

  還是要先使用grep。

  jfields$ cat order.* | sort | grep Patterns

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  jfields$ cat order.* | sort | grep Patterns | cut -d”,” -f2,5

  1, 39.99

  -1, 39.99

  我們已經(jīng)減少了數(shù)據(jù),讓會計一目了然。

  假設(shè)會計想要把訂單ID做為參考,把它放在每一行的最后,并用單引號。

  sed

  –流編輯器。用來處理文本轉(zhuǎn)換。

  下面的示例演示怎樣使用它來做到我們想要的數(shù)據(jù)。

  jfields$ cat order.* | sort | grep Patterns \

  >| sed s/”[0-9\:]* \([0-9]*\)\, \(.*\)”/”

  程序員都應(yīng)該知道什么Linux命令?每個程序員,在職業(yè)生涯的某個時刻,總會發(fā)現(xiàn)自己需要知道一些Linux方面的知識。學習啦小編分享了程序員都應(yīng)該知道的8個Linux命令,希望對大家有所幫助。

  程序員都應(yīng)該知道的8個Linux命令

  我們以一些文本舉例。假設(shè)我們有2個文件,里面有訂單關(guān)于第三方的放置地點和發(fā)送回應(yīng)。

  cat order.out.log

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  cat order.in.log

  8:22:20 111, Order Complete

  8:23:50 112, Order sent to fulfillment

  8:24:20 113, Refund sent to processing

  cat

  –追加文件并在標準輸出上打印

  jfields$ cat order.out.log

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  正如他的名字所說的,你可以串聯(lián)多個文件

  jfields$ cat order.*

  8:22:20 111, Order Complete

  8:23:50 112, Order sent to fulfillment

  8:24:20 113, Refund sent to processing

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  看到效果了,但我們可以提高其可讀性。

  sort

  –對文本文件進行行排序,這里使用排序是不錯的選擇

  jfields$ cat order.* | sort

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:22:20 111, Order Complete

  8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99

  8:23:50 112, Order sent to fulfillment

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:24:20 113, Refund sent to processing

  上面顯示了我們想要看到的效果,但是這只是小文件。而真實的數(shù)據(jù)是很大的,有些是你不想要的數(shù)據(jù)怎么辦?

  grep

  grep, egrep, fgrep–進行匹配輸出

  假設(shè)我只關(guān)心給PofEAA的訂單,使用grep就可以做到。

  jfields$ cat order.* | sort | grep Patterns

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  假設(shè)訂單113里面發(fā)生了一些問題,你想看到關(guān)于113的所有訂單信息。沒錯,grep能幫你。

  jfields$ cat order.* | sort | grep “:\d\d 113, ”

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:24:20 113, Refund sent to processing

  你會發(fā)現(xiàn)在表達式里面不止有113,這是因為113也可能出現(xiàn)在價格里面,或者產(chǎn)品里面,這樣做是嚴格限制其查找結(jié)果。

  現(xiàn)在我們已經(jīng)發(fā)出退貨訂單的信息,我們每日也要給會計發(fā)送銷售統(tǒng)計。他們要求每個PofEAA的項目,但他們只關(guān)心數(shù)量和價格,我們要把

  不需要的部分刪減掉。

  cut

  –從文件的每一行刪除一部分

  還是要先使用grep。

  jfields$ cat order.* | sort | grep Patterns

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  jfields$ cat order.* | sort | grep Patterns | cut -d”,” -f2,5

  1, 39.99

  -1, 39.99

  我們已經(jīng)減少了數(shù)據(jù),讓會計一目了然。

  假設(shè)會計想要把訂單ID做為參考,把它放在每一行的最后,并用單引號。

  sed

  –流編輯器。用來處理文本轉(zhuǎn)換。

  下面的示例演示怎樣使用它來做到我們想要的數(shù)據(jù)。

  jfields$ cat order.* | sort | grep Patterns \

  >| sed s/”[0-9\:]* \([0-9]*\)\, \(.*\)”/”

  程序員都應(yīng)該知道什么Linux命令?每個程序員,在職業(yè)生涯的某個時刻,總會發(fā)現(xiàn)自己需要知道一些Linux方面的知識。學習啦小編分享了程序員都應(yīng)該知道的8個Linux命令,希望對大家有所幫助。

  程序員都應(yīng)該知道的8個Linux命令

  我們以一些文本舉例。假設(shè)我們有2個文件,里面有訂單關(guān)于第三方的放置地點和發(fā)送回應(yīng)。

  cat order.out.log

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  cat order.in.log

  8:22:20 111, Order Complete

  8:23:50 112, Order sent to fulfillment

  8:24:20 113, Refund sent to processing

  cat

  –追加文件并在標準輸出上打印

  jfields$ cat order.out.log

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  正如他的名字所說的,你可以串聯(lián)多個文件

  jfields$ cat order.*

  8:22:20 111, Order Complete

  8:23:50 112, Order sent to fulfillment

  8:24:20 113, Refund sent to processing

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  看到效果了,但我們可以提高其可讀性。

  sort

  –對文本文件進行行排序,這里使用排序是不錯的選擇

  jfields$ cat order.* | sort

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:22:20 111, Order Complete

  8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99

  8:23:50 112, Order sent to fulfillment

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:24:20 113, Refund sent to processing

  上面顯示了我們想要看到的效果,但是這只是小文件。而真實的數(shù)據(jù)是很大的,有些是你不想要的數(shù)據(jù)怎么辦?

  grep

  grep, egrep, fgrep–進行匹配輸出

  假設(shè)我只關(guān)心給PofEAA的訂單,使用grep就可以做到。

  jfields$ cat order.* | sort | grep Patterns

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  假設(shè)訂單113里面發(fā)生了一些問題,你想看到關(guān)于113的所有訂單信息。沒錯,grep能幫你。

  jfields$ cat order.* | sort | grep “:\d\d 113, ”

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:24:20 113, Refund sent to processing

  你會發(fā)現(xiàn)在表達式里面不止有113,這是因為113也可能出現(xiàn)在價格里面,或者產(chǎn)品里面,這樣做是嚴格限制其查找結(jié)果。

  現(xiàn)在我們已經(jīng)發(fā)出退貨訂單的信息,我們每日也要給會計發(fā)送銷售統(tǒng)計。他們要求每個PofEAA的項目,但他們只關(guān)心數(shù)量和價格,我們要把

  不需要的部分刪減掉。

  cut

  –從文件的每一行刪除一部分

  還是要先使用grep。

  jfields$ cat order.* | sort | grep Patterns

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  jfields$ cat order.* | sort | grep Patterns | cut -d”,” -f2,5

  1, 39.99

  -1, 39.99

  我們已經(jīng)減少了數(shù)據(jù),讓會計一目了然。

  假設(shè)會計想要把訂單ID做為參考,把它放在每一行的最后,并用單引號。

  sed

  –流編輯器。用來處理文本轉(zhuǎn)換。

  下面的示例演示怎樣使用它來做到我們想要的數(shù)據(jù)。

  jfields$ cat order.* | sort | grep Patterns \

  >| sed s/”[0-9\:]* \([0-9]*\)\, \(.*\)”/”

  程序員都應(yīng)該知道什么Linux命令?每個程序員,在職業(yè)生涯的某個時刻,總會發(fā)現(xiàn)自己需要知道一些Linux方面的知識。學習啦小編分享了程序員都應(yīng)該知道的8個Linux命令,希望對大家有所幫助。

  程序員都應(yīng)該知道的8個Linux命令

  我們以一些文本舉例。假設(shè)我們有2個文件,里面有訂單關(guān)于第三方的放置地點和發(fā)送回應(yīng)。

  cat order.out.log

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  cat order.in.log

  8:22:20 111, Order Complete

  8:23:50 112, Order sent to fulfillment

  8:24:20 113, Refund sent to processing

  cat

  –追加文件并在標準輸出上打印

  jfields$ cat order.out.log

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  正如他的名字所說的,你可以串聯(lián)多個文件

  jfields$ cat order.*

  8:22:20 111, Order Complete

  8:23:50 112, Order sent to fulfillment

  8:24:20 113, Refund sent to processing

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  看到效果了,但我們可以提高其可讀性。

  sort

  –對文本文件進行行排序,這里使用排序是不錯的選擇

  jfields$ cat order.* | sort

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:22:20 111, Order Complete

  8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99

  8:23:50 112, Order sent to fulfillment

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:24:20 113, Refund sent to processing

  上面顯示了我們想要看到的效果,但是這只是小文件。而真實的數(shù)據(jù)是很大的,有些是你不想要的數(shù)據(jù)怎么辦?

  grep

  grep, egrep, fgrep–進行匹配輸出

  假設(shè)我只關(guān)心給PofEAA的訂單,使用grep就可以做到。

  jfields$ cat order.* | sort | grep Patterns

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  假設(shè)訂單113里面發(fā)生了一些問題,你想看到關(guān)于113的所有訂單信息。沒錯,grep能幫你。

  jfields$ cat order.* | sort | grep “:\d\d 113, ”

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:24:20 113, Refund sent to processing

  你會發(fā)現(xiàn)在表達式里面不止有113,這是因為113也可能出現(xiàn)在價格里面,或者產(chǎn)品里面,這樣做是嚴格限制其查找結(jié)果。

  現(xiàn)在我們已經(jīng)發(fā)出退貨訂單的信息,我們每日也要給會計發(fā)送銷售統(tǒng)計。他們要求每個PofEAA的項目,但他們只關(guān)心數(shù)量和價格,我們要把

  不需要的部分刪減掉。

  cut

  –從文件的每一行刪除一部分

  還是要先使用grep。

  jfields$ cat order.* | sort | grep Patterns

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  jfields$ cat order.* | sort | grep Patterns | cut -d”,” -f2,5

  1, 39.99

  -1, 39.99

  我們已經(jīng)減少了數(shù)據(jù),讓會計一目了然。

  假設(shè)會計想要把訂單ID做為參考,把它放在每一行的最后,并用單引號。

  sed

  –流編輯器。用來處理文本轉(zhuǎn)換。

  下面的示例演示怎樣使用它來做到我們想要的數(shù)據(jù)。

  jfields$ cat order.* | sort | grep Patterns \

  >| sed s/”[0-9\:]* \([0-9]*\)\, \(.*\)”/”

  程序員都應(yīng)該知道什么Linux命令?每個程序員,在職業(yè)生涯的某個時刻,總會發(fā)現(xiàn)自己需要知道一些Linux方面的知識。學習啦小編分享了程序員都應(yīng)該知道的8個Linux命令,希望對大家有所幫助。

  程序員都應(yīng)該知道的8個Linux命令

  我們以一些文本舉例。假設(shè)我們有2個文件,里面有訂單關(guān)于第三方的放置地點和發(fā)送回應(yīng)。

  cat order.out.log

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  cat order.in.log

  8:22:20 111, Order Complete

  8:23:50 112, Order sent to fulfillment

  8:24:20 113, Refund sent to processing

  cat

  –追加文件并在標準輸出上打印

  jfields$ cat order.out.log

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  正如他的名字所說的,你可以串聯(lián)多個文件

  jfields$ cat order.*

  8:22:20 111, Order Complete

  8:23:50 112, Order sent to fulfillment

  8:24:20 113, Refund sent to processing

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  看到效果了,但我們可以提高其可讀性。

  sort

  –對文本文件進行行排序,這里使用排序是不錯的選擇

  jfields$ cat order.* | sort

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:22:20 111, Order Complete

  8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99

  8:23:50 112, Order sent to fulfillment

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:24:20 113, Refund sent to processing

  上面顯示了我們想要看到的效果,但是這只是小文件。而真實的數(shù)據(jù)是很大的,有些是你不想要的數(shù)據(jù)怎么辦?

  grep

  grep, egrep, fgrep–進行匹配輸出

  假設(shè)我只關(guān)心給PofEAA的訂單,使用grep就可以做到。

  jfields$ cat order.* | sort | grep Patterns

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  假設(shè)訂單113里面發(fā)生了一些問題,你想看到關(guān)于113的所有訂單信息。沒錯,grep能幫你。

  jfields$ cat order.* | sort | grep “:\d\d 113, ”

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:24:20 113, Refund sent to processing

  你會發(fā)現(xiàn)在表達式里面不止有113,這是因為113也可能出現(xiàn)在價格里面,或者產(chǎn)品里面,這樣做是嚴格限制其查找結(jié)果。

  現(xiàn)在我們已經(jīng)發(fā)出退貨訂單的信息,我們每日也要給會計發(fā)送銷售統(tǒng)計。他們要求每個PofEAA的項目,但他們只關(guān)心數(shù)量和價格,我們要把

  不需要的部分刪減掉。

  cut

  –從文件的每一行刪除一部分

  還是要先使用grep。

  jfields$ cat order.* | sort | grep Patterns

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  jfields$ cat order.* | sort | grep Patterns | cut -d”,” -f2,5

  1, 39.99

  -1, 39.99

  我們已經(jīng)減少了數(shù)據(jù),讓會計一目了然。

  假設(shè)會計想要把訂單ID做為參考,把它放在每一行的最后,并用單引號。

  sed

  –流編輯器。用來處理文本轉(zhuǎn)換。

  下面的示例演示怎樣使用它來做到我們想要的數(shù)據(jù)。

  jfields$ cat order.* | sort | grep Patterns \

  >| sed s/”[0-9\:]* \([0-9]*\)\, \(.*\)”/”

  程序員都應(yīng)該知道什么Linux命令?每個程序員,在職業(yè)生涯的某個時刻,總會發(fā)現(xiàn)自己需要知道一些Linux方面的知識。學習啦小編分享了程序員都應(yīng)該知道的8個Linux命令,希望對大家有所幫助。

  程序員都應(yīng)該知道的8個Linux命令

  我們以一些文本舉例。假設(shè)我們有2個文件,里面有訂單關(guān)于第三方的放置地點和發(fā)送回應(yīng)。

  cat order.out.log

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  cat order.in.log

  8:22:20 111, Order Complete

  8:23:50 112, Order sent to fulfillment

  8:24:20 113, Refund sent to processing

  cat

  –追加文件并在標準輸出上打印

  jfields$ cat order.out.log

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  正如他的名字所說的,你可以串聯(lián)多個文件

  jfields$ cat order.*

  8:22:20 111, Order Complete

  8:23:50 112, Order sent to fulfillment

  8:24:20 113, Refund sent to processing

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  看到效果了,但我們可以提高其可讀性。

  sort

  –對文本文件進行行排序,這里使用排序是不錯的選擇

  jfields$ cat order.* | sort

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:22:20 111, Order Complete

  8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99

  8:23:50 112, Order sent to fulfillment

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:24:20 113, Refund sent to processing

  上面顯示了我們想要看到的效果,但是這只是小文件。而真實的數(shù)據(jù)是很大的,有些是你不想要的數(shù)據(jù)怎么辦?

  grep

  grep, egrep, fgrep–進行匹配輸出

  假設(shè)我只關(guān)心給PofEAA的訂單,使用grep就可以做到。

  jfields$ cat order.* | sort | grep Patterns

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  假設(shè)訂單113里面發(fā)生了一些問題,你想看到關(guān)于113的所有訂單信息。沒錯,grep能幫你。

  jfields$ cat order.* | sort | grep “:\d\d 113, ”

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:24:20 113, Refund sent to processing

  你會發(fā)現(xiàn)在表達式里面不止有113,這是因為113也可能出現(xiàn)在價格里面,或者產(chǎn)品里面,這樣做是嚴格限制其查找結(jié)果。

  現(xiàn)在我們已經(jīng)發(fā)出退貨訂單的信息,我們每日也要給會計發(fā)送銷售統(tǒng)計。他們要求每個PofEAA的項目,但他們只關(guān)心數(shù)量和價格,我們要把

  不需要的部分刪減掉。

  cut

  –從文件的每一行刪除一部分

  還是要先使用grep。

  jfields$ cat order.* | sort | grep Patterns

  8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99

  jfields$ cat order.* | sort | grep Patterns | cut -d”,” -f2,5

  1, 39.99

  -1, 39.99

  我們已經(jīng)減少了數(shù)據(jù),讓會計一目了然。

  假設(shè)會計想要把訂單ID做為參考,把它放在每一行的最后,并用單引號。

  sed

  –流編輯器。用來處理文本轉(zhuǎn)換。

  下面的示例演示怎樣使用它來做到我們想要的數(shù)據(jù)。

  jfields$ cat order.* | sort | grep Patterns \

  >| sed s/”[0-9\:]* \([0-9]*\)\, \(.*\)”/”\2, ‘\1′”/

  1, Patterns of Enterprise Architecture, Kindle edition, 39.99, '111′

  -1, Patterns of Enterprise Architecture, Kindle edition, 39.99, '113′

  lmp-jfields01:~ jfields$ cat order.* | sort | grep Patterns \

  >| sed s/”[0-9\:]* \([0-9]*\)\, \(.*\)”/”\2, ‘\1′”/ | cut -d”,” -f1,4,5

  1, 39.99, '111′

  -1, 39.99, '113′

  這是一個正則表達式,但沒什么復(fù)雜的。做以下事情

  1.刪除時間

  2.捕獲訂單號

  3.刪除逗號和訂單號后面的空格

  4.捕獲此行的其余部分

  一旦我們看到了我們需要的數(shù)據(jù),可以使用\1&\2讓輸出數(shù)據(jù)符合我們的格式要求。

  uniq

  –去除重復(fù)行

  下面的示例演示如何grep的唯一相關(guān)的交易,削減不必要的信息,并獲得計數(shù)。

  jfields$ cat order.out.log | grep “\(Kindle\|Hardcover\)” | cut -d”,” -f3 | sort | uniq -c

  1 Joy of Clojure

  2 Patterns of Enterprise Architecture

  jfields$ cat order.out.log | grep “\(Kindle\|Hardcover\)” | cut -d”,” -f3 | sort | uniq

  Joy of Clojure

  Patterns of Enterprise Architecture

  find

  –在目錄里找文件

  假設(shè)這2個文本文件存在于我們的主目錄,我們不必知道他們的全名。

  jfields$ find /Users -name “order*”

  Users/jfields/order.in.log

  Users/jfields/order.out.log

  當然還有很多選項,但99%的情況下我這么做。

  less

  –在一個文件里面向前向后移動

  讓我們回到最簡單的cat|sort的例子。你可以向前搜索使用”/”,向后使用”?”,2者都可以使用正則表達式。

  jfields$ cat order* | sort | less

  你可以試試/113.*,這將突出顯示訂單113。你可以使用?.*112,也將突出顯示訂單112,你可以用'q'退出。

 

看過“程序員都應(yīng)該知道什么Linux命令”的人還看了:

1.linux下free命令使用方法

2.Linux下nl命令怎么用

3.Linux命令如何連接

4.Linux下traceroute命令怎么用

5.mv命令怎么用

6.11個很有用的Linux 命令

, ‘ class="main">