我来测试cat向文档追加内容的功能;
OK?
OK~
北南 呈上
cat 连接多个文件的内容并且输出到一个新文件中;
假设我们有sir01.txt、sir02.tx和sir03.txt ,并且内容如下;
[root@localhost ~]# cat sir01.txt
123456
i am testing
[root@localhost ~]# cat sir02.txt
56789
BeiNan Tested
[root@localhost ~]# cat sir03.txt
09876
linuxsir.org testing
我想通过cat 把sir01.txt、sir02.txt及sir03.txt
三个文件连接在一起(也就是说把这三个文件的内容都接在一起)并输出到一个新的文件sir04.txt 中。
注意:其原理是把三个文件的内容连接起来,然后创建sir04.txt文件,并且把几个文件的内容同时写入sir04.txt中。特别值得一提的是,如果您输入到一个已经存在的sir04.txt
文件,会把sir04.txt内容清空。
[root@localhost ~]# cat sir01.txt sir02.txt sir03.txt > sir04.txt
[root@localhost ~]# more sir04.txt
123456
i am testing
56789
BeiNan Tested
09876
linuxsir.org testing
cat 把一个或多个已存在的文件内容,追加到一个已存在的文件中
[root@localhost ~]# cat sir00.txt
linuxsir.org forever
[root@localhost ~]# cat sir01.txt sir02.txt sir03.txt >> sir00.txt
[root@localhost ~]# cat sir00.txt
linuxsir.org forever
123456
i am testing
56789
BeiNan Tested
09876
linuxsir.org testing
警告:我们要知道>意思是创建,>>是追加。千万不要弄混了。造成失误可不是闹着玩的;
2、more 文件内容或输出查看工具;
more 是我们最常用的工具之一,最常用的就是显示输出的内容,然后根据窗口的大小进行分页显示,然后还能提示文件的百分比;
[root@localhost ~]# more /etc/profile
2.1 more 的语法、参数和命令;
more [参数选项] [文件]
参数如下:
+num 从第num行开始显示;
-num 定义屏幕大小,为num行;
+/pattern 从pattern 前两行开始显示;
-c 从顶部清屏然后显示;
-d 提示Press space to continue, 'q' to quit.(按空格键继续,按q键退出),禁用响铃功能;
-l 忽略Ctrl+l (换页)字符;
-p 通过清除窗口而不是滚屏来对文件进行换页。和-c参数有点相似;
-s 把连续的多个空行显示为一行;
-u 把文件内容中的下划线去掉
退出more的动作指令是q
(责任编辑:luwei) |