一本一本久久a久久精品综合,啦啦啦视频免费播放在线观看,六十六十路熟妇高熟在线,老头解开奶罩吸奶头高潮视频,一本久久a久久免费精品不卡,顶级欧美熟妇高清xxxxx,爆乳熟妇一区二区三区霸乳,无码h黄肉3d动漫在线观看

綠色資源網:您身邊最放心的安全下載站! 最新軟件|熱門排行|軟件分類|軟件專題|廠商大全

綠色資源網

技術教程
您的位置:首頁操作系統linux → 13個Cat命令管理文件實例匯總

13個Cat命令管理文件實例匯總

我要評論 2013/12/23 19:04:53 來源:綠色資源網 編輯:www.nesang.cn [ ] 評論:0 點擊:235次

在Linux系統中,大多數配置文件、日志文件,甚至shell腳本都使用文本文件格式,因此,Linux系統存在著多種文本編輯器,但當你僅僅想要查看一下這些文件的內容時,可使用一個簡單的命令-cat。

cat手冊里這樣描述:

cat命令讀取文件內容,并輸出到標準設備上面。

cat是一條linux內置命令. 幾乎所有linux發行版都內置(譯注:或者說我從未聽說過不內置cat命令的發行版)。接下來,讓我們開始學習如何使用。

1. 顯示文件內容

最簡單的方法是直接輸入‘cat file_name’.

# cat /etc/issue
 
CentOS release 5.10 (Final)
Kernel \r on an \m

2. 同時顯示行號

當在讀取內容很多的配置文件時,如果同時顯示行號將會使操作變簡單,加上-n參數可以實現.

# cat -n /etc/ntp.conf
 
1 # Permit time synchronization our time resource but do not
2 # permit the source to query or modify the service on this system
3 restrict default kod nomodify notrap nopeer noquery
4 restrict -6 default kod nomodify notrap nopeer noquery
5
6 # Permit all access over the loopback interface. This could be
7 # tightened as well, but to do so would effect some of the
8 # administration functions
9 restrict 127.0.0.1
10 restrict -6 ::1

3. 在非空格行首顯示行號

類似于-n參數,-b也可以顯示行號。區別在于-b只在非空行前顯示行號。

#cat -b /etc/ntp.conf
 
1 # Permit time synchronization our time resource but do not
2 # permit the source to query or modify the service on this system
3 restrict default kod nomodify notrap nopeer noquery
4 restrict -6 default kod nomodify notrap nopeer noquery
 
5 # Permit all access over the loopback interface. This could be
6 # tightened as well, but to do so would effect some of the
7 # administration functions
8 restrict 127.0.0.1
9 restrict -6 ::1

4. 顯示tab制表符

當你想要顯示文本中的tab制表位時. 可使用-T參數. 它會在輸入結果中標識為 ^I .

# cat -T /etc/hosts
 
# Do not remove the following line, or various programs 
# that require network functionality will fail.
127.0.0.1^I^Ilocalhost.localdomain localhost
::1^I^Ilocalhost6.localdomain6 localhost6

5. 顯示換行符

-E參數在每行結尾使用 $ 表示換行符。如下所示 :

# cat -E /etc/hosts
 
# Do not remove the following line, or various programs$
# that require network functionality will fail.$
127.0.0.1 localhost.localdomain localhost$
::1 localhost6.localdomain6 localhost6$

6. 同時顯示制表符及換行符

當你想要同時達到-T及-E的效果, 可使用-A參數.

# cat -A /etc/hosts
 
# Do not remove the following line, or various programs$
# that require network functionality will fail.$
127.0.0.1^I^Ilocalhost.localdomain localhost$
::1^I^Ilocalhost6.localdomain6 localhost6$

7. 分屏顯示

當文件內容顯示超過了你的屏幕大小, 可結合cat命令與其它命令分屏顯示。使用管道符 ( | )來連接。

# cat /proc/meminfo | less
 
# cat /proc/meminfo | more

在less與more顯示結果的區別在于less參數可pageup及pagedown上下翻滾。而more僅能使用空格向下翻屏。

8. 同時查看2個文件中的內容

位于/root文件夾里有兩個文件取名linux及desktop,每個文件含有以下內容 :

Linux : ubuntu, centos, redhat, mint and slackware

Desktop : gnome kde, xfce, enlightment, and cinnamon

當你想同時查看兩文件中的內容時,可按如下方法 :

# cat /root/linux /root/desktop
 
ubuntu
centos
redhat
mint
slackware
gnome
kde
xfce
enlightment
cinnamon

9. 排序顯示

類似. 你也可以結合cat命令與其它命令來進行自定義輸出. 如結合 sort ,通過管道符對內容進行排序顯示。舉例 :

# cat /root/linux | sort
 
centos
mint
redhat
slackware
Ubuntu

10. 輸入重定向

你也可將顯示結果輸出重定向到屏幕或另一個文件。 只需要使用 > 符號(大于號)即可輸出生成到另一個文件。

# cat /root/linux > /root/linuxdistro

以上命令會生成一個與/root/linux內容一模一樣的叫linuxdistro的文件.

11. 新建文件

Linux下有多種方法新建文件。其中使用cat就是方法之一.

# cat > operating_system
 
Unix
Linux
Windows
MacOS

當你輸入cat > operatingsystem,它會生成一個operatingsystem的文件。然后下面會顯示空行。此時你可輸入內容。比如我們輸入Unix, Linux, Windows 和 MacOS, 輸入完成后,按Ctrl-D存盤退出cat。此時你會發現當前文件夾下會生成一個包含你剛才輸入內容的叫operating_system的文件。

12.向文件中追加內容

當你使用兩個 > 符時, 會將第一個文件中的內容追加到第二個文件的末尾。 舉例 :

# cat /root/linux >> /root/desktop
 
# cat /root/desktop

它會將 /root/linux的內容追加到/root/desktop文件的末尾。

第二個文件的內容將會變成這樣:

gnome
kde
xfce
enlightment
cinnamon
ubuntu
centos
redhat
mint
slackware

13. 重定向輸入

你可使用 <命令(小于號)將文件輸入到cat中.

# cat < /root/linux

上面命令表示 /root/linux中的內容作為cat的輸入。屏幕上顯示如下 :

ubuntu
centos
redhat
mint
slackware

為了更清楚表示它的意義,我們使用以下命令 :

# cat < /root/linux | sort > linux-sort

此命令這樣理解: 從/root/linux中讀取內容,然后排序,將結果輸出并生成linux-sort新文件

然后我們看看linux-sort中的內容 :

centos
mint
redhat
slackware
ubuntu

以上是一些cat命令的日常基本應用. 更多相關你可從cat命令手冊中學到并記得經常練習它們.


via: http://linoxide.com/linux-command/13-cat-command-examples/

譯者:hongchuntang 校對:Caroline

關鍵詞:Cat命令

閱讀本文后您有什么感想? 已有 人給出評價!

  • 0 歡迎喜歡
  • 0 白癡
  • 0 拜托
  • 0 哇
  • 0 加油
  • 0 鄙視
主站蜘蛛池模板: 久久婷婷人人澡人人爽人人爱| 伊人久久大香线蕉av色婷婷色| 久久露脸国产精品| 国产92成人精品视频免费| 国产女人高潮抽搐叫床视频| 日日碰狠狠添天天爽无码| 久久久久人妻精品一区三寸| 曰本丰满熟妇xxxx性| 八戒影视在线观看免费| 亚洲人成网站18禁止无码| 18禁在线永久免费观看| 丰满的女邻居2| 亚洲成av人在线观看网站| 久久久久国产一区二区| 女人另类牲交zozozo| 午夜爽爽爽男女免费观看影院| babescom欧美熟妇大白屁股| 在线免费观看| 久久av高潮av无码av喷吹| 一个人的视频全免费观看中国| 扒开老师内衣吸她奶头| 国产在线永久视频| 裸体跳舞xxxx裸体跳舞| 久久影院午夜理论片无码| 欧美性受xxxx黑人xxxx| 国精产品一二三区传媒公司| 国产成人av三级在线观看| 三年片免费观看大全国语| 亚洲精品久久中文字幕| 性裸交a片一区二区三区| 中文字幕日韩精品无码内射| 麻豆一区二区大豆行情| 上海少妇高潮狂叫喷水了| 永久免费观看美女裸体的网站| 国产精品午夜福利视频234区| 国产色婷婷五月精品综合在线 | 婷婷色怡春院| 中文www天堂| 国产美女牲交视频| 亚州日本乱码一区二区三区| 国产精品久久久久久无码五月|