Linux命令cat运用讲解lianxi_第1页
Linux命令cat运用讲解lianxi_第2页
Linux命令cat运用讲解lianxi_第3页
Linux命令cat运用讲解lianxi_第4页
Linux命令cat运用讲解lianxi_第5页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、linux命令cat运用讲解linux 命令 cat - concatenate files and print on the standard output 把文件连接后输出到屏幕 上,其实就是查看文件内容。你们知道什么是linux命令么这个非常高深的运用技术将由我來非常讲解,linux命令 nb在哪呢,下面我来进入讲述linux命令的无限领域。linux 命令 cat - concatenate files and print on the standard output 把文件连接后输出到屏幕 上,其实就是查看文件内容。synopsiscat option filedescription

2、concatenate file(s), or standard input, to standard output.-a,show-allequivalent to -vet -等同与参数-vetbnumber-nonblanknumber nonblank output lines 一对空白行不编号,与有相似。-e,equivalent to -ve 一等同与参数ve-e,show-ends display $ at end of each line -每行以$符号为行结尾-n,number number all output lines 由1开始对所有输岀的行数编号-s,squeeze-

3、blank never more than one single blank line -当遇到连续 2 行以上的空白彳亍,只 保留一行空白行t,equivalent to -vt-t,show-tabsdisplay tab characters as ai-uxignored)-v,show-nonprintinguse a and m- notation, except for lfd and tablinux命令练习:frootcentos4 ok_0081# cat mytesthello world!hello world 1hello world 2hello world 3ro

4、otcentos4 ok_008j# cat -n mytesthello world!hello world 1hello world 2hello world 3lrootcentos4 ok_008j# cat -b mytest1 hello world!2hello world 13hello world 24hello world 3从以上linux命令 我们可以验证与b的差异。rootcentos4 ok_008# cat -b -e mytest1 hello world !$2hello world 1$3hello world 2$4hello world 3$每行以$符号

5、为行结尾现在想合并mytest和okicst两个文件的内容成一个新的文件newtest.txtrootcentos4 ok_008# is -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-rr 1 root root 21 sep 17 20:45 oktestrootcentos4 ok_008# cat mytest oktest » newtest.txtrootcentos4 ok_008j# is -ltotal 32-rw

6、-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-rr 1 root root 21 sep 17 20:45 oktest 查看新的文件 newtest.txt 的内容:frootcentos4 ok_008# cat -b newtest.txt1 hello world!2 hello world 13 hello world 24 hello world 35 this

7、 is a test file.合并两个文件的内容jootcentos4 ok_008j# cat mytest oktest > newtest 1 .txtrootcentos4 ok_008# is -ltotal 401 root root 59 sep 18 19:48 mytest-rw-r-r- 1 root root 80 sep 18 19:56 newtestl.txtrw-rr 1 root root 80 sep 18 19:53 newtest.txtdrwxr-xr-x 3 root root 4096 sep 13 22:51 okrw-r-r- 1 roo

8、t root 21 sep 17 20:45 oktestrootcentos4 ok_008# cat -b newtestl.txt1 hello world!2 hello world 13 hello world 24 hello world 35 this is a test file.我们仔细会发现 cat mytest oktest > newtest 1 .txt 和 cat mytest oktest » newtest.txt 返冋 的结果在这里相同。其实根据linux常用命令 全集的例子:cat -n textfile 1 > textfile2把

9、textfile 1的档案内容加上行号后输入textfile2这个档案里cat -b textfile 1 textfile2 » textfile3把textfile 1和textfile2的档案内容加上行号(空白行不加)z后将内容附可以看出 两个linux命令 的差异,这里就不多写例子。linux命令清空某个文件的内容:rootcentos4 ok_008# cat /dev/null > mytestrootcentos4 ok_008# cat -b mytestfrootcentos4 ok_008# is -1total 52-rw-rr 1 root root 0

10、 sep 18 20:05 mytest-rw-rr 1 root root 80 sep 18 19:56 newtestl.txt-rw-r-r- 1 root root 93 sep 18 20:01 newtest3.txt-rw-rr- 1 root root 93 sep 18 20:01 newtest4.txt-rw-rr 1 root root 80 sep 18 19:53 newtest.txtdrwxr-xr-x 3 root root 4096 sep 13 22:51 ok-rw-rr- 1 root root 34 sep 18 20:00 oktestlinux

11、命令创建一个新的文件:frootcentos4 ok_008# cat >new.txt 一按 ctrl + c 结束录入rootcentos4 ok_008# is -1total 561 root root 0 sep 18 20:05 mytest-rw-r-r- 1 root root 80 sep 18 19:56 newtestl.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.txt1 root root 80 sep 18 19

12、:53 newtest.txt-rw-rr 1 root root 0 sep 18 20:07 new.txtdrwxr-xr-x 3 root root 4096 sep 13 22:51 ok-rw-rr 1 root root 34 sep 18 20:00 oktestlinux命令温习以前的rmlinux命令 把一些刚才临吋建立的文件(如 newtest 1 .txt,newtest3.txt,newtest4.txt,newtest.txt.new.txt)®*除掉:frootcentos4 ok_0081# rm newtestl.txt newttest3.txt

13、newtest4.txt newtest.txtrm: remove regular file "newtestl.txt1? yrm: cannot lstatvnewttest3.txt1: no such file or directoryrm: remove regular file、newtest4.txt1? yrm: remove regular fileewtest.txt1? y frootcentos4 ok_008# rm newtest3.txt rm: remove regular file vnewtest3.txt*? y rootcentos4 ok_

14、008# is -1 total 24-rw-r-r- 1 root root 0 sep 18 20:05 mytest-rw-rr 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 rootcentos4 ok_008# rm newt.txt rm: cannot lstat "newt.txt1: no such file or directory rootcentos4 ok_0()8# rm new.txt rm

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论