亚洲欧美精品沙发,日韩在线精品视频,亚洲Av每日更新在线观看,亚洲国产另类一区在线5

<pre id="hdphd"></pre>

  • <div id="hdphd"><small id="hdphd"></small></div>
      學(xué)習(xí)啦>學(xué)習(xí)電腦>操作系統(tǒng)>Linux教程>

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

      時(shí)間: 春健736 分享

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

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

        我們以一些文本舉例。假設(shè)我們有2個(gè)文件,里面有訂單關(guān)于第三方的放置地點(diǎ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

        –追加文件并在標(biāo)準(zhǔn)輸出上打印

        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

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

        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

        –對(duì)文本文件進(jìn)行行排序,這里使用排序是不錯(cuò)的選擇

        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í)的數(shù)據(jù)是很大的,有些是你不想要的數(shù)據(jù)怎么辦?

        grep

        grep, egrep, fgrep–進(jìn)行匹配輸出

        假設(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ā)生了一些問(wèn)題,你想看到關(guān)于113的所有訂單信息。沒(méi)錯(cuò),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

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

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

        不需要的部分刪減掉。

        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ù),讓會(huì)計(jì)一目了然。

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

        sed

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

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

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

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

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

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

        我們以一些文本舉例。假設(shè)我們有2個(gè)文件,里面有訂單關(guān)于第三方的放置地點(diǎ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

        –追加文件并在標(biāo)準(zhǔn)輸出上打印

        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

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

        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

        –對(duì)文本文件進(jìn)行行排序,這里使用排序是不錯(cuò)的選擇

        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í)的數(shù)據(jù)是很大的,有些是你不想要的數(shù)據(jù)怎么辦?

        grep

        grep, egrep, fgrep–進(jìn)行匹配輸出

        假設(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ā)生了一些問(wèn)題,你想看到關(guān)于113的所有訂單信息。沒(méi)錯(cuò),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

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

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

        不需要的部分刪減掉。

        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ù),讓會(huì)計(jì)一目了然。

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

        sed

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

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

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

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

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

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

        我們以一些文本舉例。假設(shè)我們有2個(gè)文件,里面有訂單關(guān)于第三方的放置地點(diǎ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

        –追加文件并在標(biāo)準(zhǔn)輸出上打印

        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

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

        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

        –對(duì)文本文件進(jìn)行行排序,這里使用排序是不錯(cuò)的選擇

        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í)的數(shù)據(jù)是很大的,有些是你不想要的數(shù)據(jù)怎么辦?

        grep

        grep, egrep, fgrep–進(jìn)行匹配輸出

        假設(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ā)生了一些問(wèn)題,你想看到關(guān)于113的所有訂單信息。沒(méi)錯(cuò),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

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

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

        不需要的部分刪減掉。

        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ù),讓會(huì)計(jì)一目了然。

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

        sed

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

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

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

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

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

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

        我們以一些文本舉例。假設(shè)我們有2個(gè)文件,里面有訂單關(guān)于第三方的放置地點(diǎ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

        –追加文件并在標(biāo)準(zhǔn)輸出上打印

        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

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

        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

        –對(duì)文本文件進(jìn)行行排序,這里使用排序是不錯(cuò)的選擇

        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í)的數(shù)據(jù)是很大的,有些是你不想要的數(shù)據(jù)怎么辦?

        grep

        grep, egrep, fgrep–進(jìn)行匹配輸出

        假設(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ā)生了一些問(wèn)題,你想看到關(guān)于113的所有訂單信息。沒(méi)錯(cuò),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

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

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

        不需要的部分刪減掉。

        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ù),讓會(huì)計(jì)一目了然。

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

        sed

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

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

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

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

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

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

        我們以一些文本舉例。假設(shè)我們有2個(gè)文件,里面有訂單關(guān)于第三方的放置地點(diǎ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

        –追加文件并在標(biāo)準(zhǔn)輸出上打印

        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

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

        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

        –對(duì)文本文件進(jìn)行行排序,這里使用排序是不錯(cuò)的選擇

        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í)的數(shù)據(jù)是很大的,有些是你不想要的數(shù)據(jù)怎么辦?

        grep

        grep, egrep, fgrep–進(jìn)行匹配輸出

        假設(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ā)生了一些問(wèn)題,你想看到關(guān)于113的所有訂單信息。沒(méi)錯(cuò),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

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

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

        不需要的部分刪減掉。

        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ù),讓會(huì)計(jì)一目了然。

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

        sed

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

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

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

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

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

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

        我們以一些文本舉例。假設(shè)我們有2個(gè)文件,里面有訂單關(guān)于第三方的放置地點(diǎ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

        –追加文件并在標(biāo)準(zhǔn)輸出上打印

        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

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

        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

        –對(duì)文本文件進(jìn)行行排序,這里使用排序是不錯(cuò)的選擇

        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í)的數(shù)據(jù)是很大的,有些是你不想要的數(shù)據(jù)怎么辦?

        grep

        grep, egrep, fgrep–進(jìn)行匹配輸出

        假設(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ā)生了一些問(wèn)題,你想看到關(guān)于113的所有訂單信息。沒(méi)錯(cuò),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

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

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

        不需要的部分刪減掉。

        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ù),讓會(huì)計(jì)一目了然。

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

        sed

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

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

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

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

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

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

        我們以一些文本舉例。假設(shè)我們有2個(gè)文件,里面有訂單關(guān)于第三方的放置地點(diǎ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

        –追加文件并在標(biāo)準(zhǔn)輸出上打印

        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

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

        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

        –對(duì)文本文件進(jìn)行行排序,這里使用排序是不錯(cuò)的選擇

        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í)的數(shù)據(jù)是很大的,有些是你不想要的數(shù)據(jù)怎么辦?

        grep

        grep, egrep, fgrep–進(jìn)行匹配輸出

        假設(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ā)生了一些問(wèn)題,你想看到關(guān)于113的所有訂單信息。沒(méi)錯(cuò),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

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

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

        不需要的部分刪減掉。

        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ù),讓會(huì)計(jì)一目了然。

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

        sed

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

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

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

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

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

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

        我們以一些文本舉例。假設(shè)我們有2個(gè)文件,里面有訂單關(guān)于第三方的放置地點(diǎ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

        –追加文件并在標(biāo)準(zhǔn)輸出上打印

        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

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

        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

        –對(duì)文本文件進(jìn)行行排序,這里使用排序是不錯(cuò)的選擇

        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í)的數(shù)據(jù)是很大的,有些是你不想要的數(shù)據(jù)怎么辦?

        grep

        grep, egrep, fgrep–進(jìn)行匹配輸出

        假設(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ā)生了一些問(wèn)題,你想看到關(guān)于113的所有訂單信息。沒(méi)錯(cuò),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

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

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

        不需要的部分刪減掉。

        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ù),讓會(huì)計(jì)一目了然。

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

        sed

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

        下面的示例演示怎樣使用它來(lái)做到我們想要的數(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′

        這是一個(gè)正則表達(dá)式,但沒(méi)什么復(fù)雜的。做以下事情

        1.刪除時(shí)間

        2.捕獲訂單號(hào)

        3.刪除逗號(hào)和訂單號(hào)后面的空格

        4.捕獲此行的其余部分

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

        uniq

        –去除重復(fù)行

        下面的示例演示如何grep的唯一相關(guān)的交易,削減不必要的信息,并獲得計(jì)數(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個(gè)文本文件存在于我們的主目錄,我們不必知道他們的全名。

        jfields$ find /Users -name “order*”

        Users/jfields/order.in.log

        Users/jfields/order.out.log

        當(dāng)然還有很多選項(xiàng),但99%的情況下我這么做。

        less

        –在一個(gè)文件里面向前向后移動(dòng)

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

        jfields$ cat order* | sort | less

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

       

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

      1.linux下free命令使用方法

      2.Linux下nl命令怎么用

      3.Linux命令如何連接

      4.Linux下traceroute命令怎么用

      5.mv命令怎么用

      6.11個(gè)很有用的Linux 命令

      , ‘ class="main">