最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

一個(gè)簡(jiǎn)單的linux命令 cat

 更新時(shí)間:2016年12月30日 15:46:36   作者:liruopeng321  
這篇文章主要介紹了一個(gè)簡(jiǎn)單的linux命令cat,cat命令用來(lái)顯示文件內(nèi)容,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

cat命令的用途是連接文件或標(biāo)準(zhǔn)輸入并打印。這個(gè)命令常用來(lái)顯示文件內(nèi)容,或者將幾個(gè)文件連接起來(lái)顯示,或者從標(biāo)準(zhǔn)輸入讀取內(nèi)容并顯示,它常與重定向符號(hào)配合使用。

命令格式

cat [選項(xiàng)] [文件]…

命令功能

cat主要有三大功能:
1.一次顯示整個(gè)文件:cat filename
2.從鍵盤(pán)創(chuàng)建一個(gè)文件:cat > filename 只能創(chuàng)建新文件,不能編輯已有文件.
3.將幾個(gè)文件合并為一個(gè)文件:cat file1 file2 > file

命令參數(shù)

-A, –show-all 等價(jià)于 -vET
-b, –number-nonblank 對(duì)非空輸出行編號(hào)
-e 等價(jià)于 -vE
-E, –show-ends 在每行結(jié)束處顯示 $
-n, –number 對(duì)輸出的所有行編號(hào),由1開(kāi)始對(duì)所有輸出的行數(shù)編號(hào)
-s, –squeeze-blank 有連續(xù)兩行以上的空白行,就代換為一行的空白行
-t 與 -vT 等價(jià)
-T, –show-tabs 將跳格字符顯示為 ^I
-u (被忽略)
-v, –show-nonprinting 使用 ^ 和 M- 引用,除了 LFD 和 TAB 之外

使用實(shí)例

實(shí)例一:把 log2012.log 的文件內(nèi)容加上行號(hào)后輸入 log2013.log 這個(gè)文件里

命令:
cat -n log2012.log log2013.log

輸出:

[root@localhost test]# cat log2012.log 
2012-01
2012-02
======[root@localhost test]# cat log2013.log 
2013-01
2013-02
2013-03
======[root@localhost test]# cat -n log2012.log log2013.log 
  1 2012-01
  2 2012-02
  3
  4
  5 ======
  6 2013-01
  7 2013-02
  8
  9
  10 2013-03
  11 ======[root@localhost test]#

實(shí)例二:把 log2012.log 和 log2013.log 的文件內(nèi)容加上行號(hào)(空白行不加)之后將內(nèi)容附加到 log.log 里。

命令:
cat -b log2012.log log2013.log log.log
輸出:

[root@localhost test]# cat -b log2012.log log2013.log log.log
  1 2012-01
  2 2012-02
  3 ======
  4 2013-01
  5 2013-02
  6 2013-03
  7 ======[root@localhost test]#

實(shí)例三:把 log2012.log 的文件內(nèi)容加上行號(hào)后輸入 log.log 這個(gè)文件里

[root@localhost test]# cat log.log 
[root@localhost test]# cat -n log2012.log > log.log
[root@localhost test]# cat -n log.log 
  1 2012-01
  2 2012-02
  3
  4
  5 ======
[root@localhost test]#

實(shí)例四:使用here doc來(lái)生成文件

輸出:

[root@localhost test]# cat >log.txt <<EOF
> Hello
> World
> Linux
> PWD=$(pwd)
> EOF
[root@localhost test]# ls -l log.txt 
-rw-r--r-- 1 root root 37 10-28 17:07 log.txt
[root@localhost test]# cat log.txt 
Hello
World
Linux
PWD=/opt/soft/test
[root@localhost test]#

說(shuō)明:
注意粗體部分,here doc可以進(jìn)行字符串替換。

備注:

tac (反向列示)
命令:
tac log.txt
輸出:

[root@localhost test]# tac log.txt 
PWD=/opt/soft/test
Linux
World
Hello

說(shuō)明:
tac 是將 cat 反寫(xiě)過(guò)來(lái),所以他的功能就跟 cat 相反, cat 是由第一行到最后一行連續(xù)顯示在螢?zāi)簧?,?tac 則是由最后一行到第一行反向在螢?zāi)簧巷@示出來(lái)!

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

望奎县| 鸡西市| 蓝田县| 盐津县| 龙游县| 滦平县| 禄丰县| 杭锦后旗| 都安| 松滋市| 惠州市| 高雄县| 永安市| 沙坪坝区| 旅游| 手机| 禄劝| 陇南市| 乌苏市| 乐亭县| 天台县| 临江市| 宣武区| 左云县| 伽师县| 香格里拉县| 固始县| 浠水县| 汶上县| 健康| 达州市| 潢川县| 商河县| 新干县| 滁州市| 武强县| 普宁市| 康平县| 长顺县| 周宁县| 泸定县|