自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Linux命令cat運(yùn)用講解

運(yùn)維 系統(tǒng)運(yùn)維
Linux命令cat - concatenate files and print on the standard output把文件連接后輸出到屏幕上,其實(shí)就是查看文件內(nèi)容。

你們知道什么是Linux命令么這個(gè)非常高深的運(yùn)用技術(shù)將由我來(lái)非常講解,Linux命令NB在哪呢,下面我來(lái)進(jìn)入講述Linux命令的無(wú)限領(lǐng)域。

Linux命令cat - concatenate files and print on the standard output把文件連接后輸出到屏幕上,其實(shí)就是查看文件內(nèi)容。
SYNOPSIScat [OPTION] [FILEDESCRIPTIONConcatenate FILE(s), or standard input, to standard output.
-A,show-allequivalent to -vET --等同與參數(shù)-vET
-b,number-nonblanknumber nonblank output lines --對(duì)空白行不編號(hào),與-n有相似。
-e,equivalent to -vE --等同與參數(shù)-vE
-E,show-ends display $ at end of each line --每行以$符號(hào)為行結(jié)尾
-n,number number all output lines --由1開(kāi)始對(duì)所有輸出的行數(shù)編號(hào)
-s,squeeze-blank never more than one single blank line --當(dāng)遇到連續(xù)2行以上的空白行,只保留一行空白行
-t,equivalent to -vT
-T,show-tabsdisplay TAB characters as ^I
-u,(ignored)
-v,show-nonprintinguse ^ and M- notation, except for LFD and TAB

Linux命令練習(xí):
[root@CentOS4 ok_008]# cat mytestHello world!
Hello world 1
Hello world 2
hello world 3
[root@CentOS4 ok_008]# cat -n mytest
Hello world!
Hello world 1
Hello world 2
hello world 3
[root@CentOS4 ok_008]# cat -b mytest
1Hello world!
2Hello world 1
3Hello world 2
4hello world 3從以上Linux命令 我們可以驗(yàn)證 -n與 -b的差異。
[root@CentOS4 ok_008]# cat -b -E mytest
1Hello world!$
2Hello world 1$
3Hello world 2$
4hello world 3$
每行以$符號(hào)為行結(jié)尾

現(xiàn)在想合并mytest和oktest兩個(gè)文件的內(nèi)容成一個(gè)新的文件NewTest.txt[root@CentOS4 ok_008]# ls -ltotal 24-rw-r--r--  1 root root   59 Sep 18 19:48 mytestdrwxr-xr-x 3 root root 4096 Sep 13 22:51 ok-rw-r--r--  1 root root   21 Sep 17 20:45 oktest[root@CentOS4 ok_008]# cat mytest oktest >> newtest.txt[root@CentOS4 ok_008]# ls -ltotal 32-rw-r--r--  1 root root   59 Sep 18 19:48 mytest-rw-r--r--  1 root root   80 Sep 18 19:53 newtest.txtdrwxr-xr-x  3 root root 4096 Sep 13 22:51 ok-rw-r--r--  1 root root   21 Sep 17 20:45 oktest查看新的文件newtest.txt的內(nèi)容:[root@CentOS4 ok_008]# cat -b newtest.txt
1  Hello world!
2  Hello world 1
3  Hello world 2
4  hello world 3
5  this is a test file.

合并兩個(gè)文件的內(nèi)容[root@CentOS4 ok_008]# cat mytest oktest > newtest1.txt[root@CentOS4 ok_008]# ls -ltotal 40
-rw-r--r--  1 root root   59 Sep 18 19:48 mytest
-rw-r--r--  1 root root   80 Sep 18 19:56 newtest1.txt
-rw-r--r--  1 root root   80 Sep 18 19:53 newtest.txt
drwxr-xr-x  3 root root 4096 Sep 13 22:51 ok
-rw-r--r--  1 root root   21 Sep 17 20:45 oktest

[root@CentOS4 ok_008]#  cat -b newtest1.txt
1  Hello world!
2  Hello world 1
3  Hello world 2
4  hello world 3
5  this is a test file.

我們仔細(xì)會(huì)發(fā)現(xiàn)cat mytest oktest > newtest1.txt 和 cat mytest oktest >> newtest.txt 返回的結(jié)果在這里相同。其實(shí)根據(jù)《Linux常用命令 全集》的例子:cat -n textfile1 > textfile2 把 textfile1 的檔案內(nèi)容加上行號(hào)后輸入 textfile2 這個(gè)檔案里cat -b textfile1 textfile2 >> textfile3 把 textfile1 和 textfile2 的檔案內(nèi)容加上行號(hào)(空白行不加)之后將內(nèi)容附可以看出兩個(gè)Linux命令 的差異,這里就不多寫(xiě)例子。

Linux命令清空某個(gè)文件的內(nèi)容:
[root@CentOS4 ok_008]# cat /dev/null > mytest
[root@CentOS4 ok_008]# cat -b mytest
[root@CentOS4 ok_008]# ls -l
total 52
-rw-r--r--  1 root root    0 Sep 18 20:05 mytest
-rw-r--r--  1 root root   80 Sep 18 19:56 newtest1.txt
-rw-r--r--  1 root root   93 Sep 18 20:01 newtest3.txt
-rw-r--r--  1 root root   93 Sep 18 20:01 newtest4.txt
-rw-r--r--  1 root root   80 Sep 18 19:53 newtest.txt
drwxr-xr-x  3 root root 4096 Sep 13 22:51 ok
-rw-r--r--  1 root root   34 Sep 18 20:00 oktest
--明天找一下資料為什么要使用cat /dev/null > mytest能清空文件內(nèi)容。

Linux命令創(chuàng)建一個(gè)新的文件:
[root@CentOS4 ok_008]# cat >new.txt --按 CTRL + C 結(jié)束錄入
[root@CentOS4 ok_008]# ls -l
total 56
-rw-r--r--  1 root root    0 Sep 18 20:05 mytest
-rw-r--r--  1 root root   80 Sep 18 19:56 newtest1.txt
-rw-r--r--  1 root root   93 Sep 18 20:01 newtest3.txt
-rw-r--r--  1 root root   93 Sep 18 20:01 newtest4.txt
-rw-r--r--  1 root root   80 Sep 18 19:53 newtest.txt
-rw-r--r--  1 root root    0 Sep 18 20:07 new.txt
drwxr-xr-x  3 root root 4096 Sep 13 22:51 ok
-rw-r--r--  1 root root   34 Sep 18 20:00 oktest
Linux命令溫習(xí)以前的rmLinux命令 把一些剛才臨時(shí)建立的文件(如newtest1.txt,newtest3.txt,newtest4.txt,newtest.txt,new.txt)刪除掉:

[root@CentOS4 ok_008]# rm newtest1.txt newttest3.txt newtest4.txt newtest.txt
rm: remove regular file `newtest1.txt'? y
rm: cannot lstat `newttest3.txt': No such file or directory
rm: remove regular file `newtest4.txt'? y
rm: remove regular file `newtest.txt'? y
[root@CentOS4 ok_008]# rm newtest3.txt
rm: remove regular file `newtest3.txt'? y
[root@CentOS4 ok_008]# ls -l
total 24
-rw-r--r--  1 root root    0 Sep 18 20:05 mytest
-rw-r--r--  1 root root    0 Sep 18 20:07 new.txt
drwxr-xr-x  3 root root 4096 Sep 13 22:51 ok
-rw-r--r--  1 root root   34 Sep 18 20:00 oktest
[root@CentOS4 ok_008]# rm newt.txt
rm: cannot lstat `newt.txt': No such file or directory
[root@CentOS4 ok_008]# rm new.txt
rm: remove regular empty file `new.txt'? y
[root@CentOS4 ok_008]# ls -l
total 20
-rw-r--r--  1 root root    0 Sep 18 20:05 mytest
drwxr-xr-x  3 root root 4096 Sep 13 22:51 ok
-rw-r--r--  1 root root   34 Sep 18 20:00 oktest
今天就學(xué)到這里,休息一下,呵呵。
以上介紹Linux命令應(yīng)用。

【編輯推薦】

  1. 一些高效的Linux命令行操作
  2. 菜鳥(niǎo)筆記:Linux命令大全
  3. 命令簡(jiǎn)介:文件和目錄管理的基本Linux命令
  4. 掌握cat學(xué)好Linux命令
  5. 簡(jiǎn)單解說(shuō)Linux命令輸出與命令替換
責(zé)任編輯:佚名 來(lái)源: CSDN
相關(guān)推薦

2010-05-07 17:12:45

Unix route

2010-01-05 16:49:34

2010-06-24 11:16:17

Linux Cat命令詳解

2010-06-24 14:08:25

Linux Cat命令

2023-07-23 19:26:18

Linuxcat 命令

2010-06-24 14:12:20

Linux Cat命令

2022-08-10 13:12:04

Linuxcat命令

2010-06-24 14:38:48

Linux Cat命令

2010-06-24 14:49:00

Linux Cat詳解

2010-06-24 14:16:31

Linux Cat命令

2009-10-19 17:10:37

Linux文件命令

2009-12-14 11:29:19

Linux查看命令

2010-04-19 17:34:02

Unix操作系統(tǒng)

2010-06-24 14:24:39

Linux Cat命令

2009-10-22 10:50:47

linux磁盤管理命令

2009-10-27 09:26:26

linux系統(tǒng)監(jiān)控命令

2018-04-16 10:12:46

Linux命令gunzip

2009-12-21 11:22:37

Linux網(wǎng)絡(luò)操作命令

2009-12-24 17:04:18

nohup命令

2013-10-21 15:20:27

Linux命令cat 命令
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)