linux cat命令详解
来源:互联网 发布:淘宝九块九包邮怎么弄 编辑:程序博客网 时间:2024/06/09 13:56
cat主要有三大功能:
1.查看文件内容,一次显示整个文件。$cat filename
1.查看文件内容,一次显示整个文件。$cat filename
参数:
-n 或 --number 由 1 开始对所有输出的行数编号
-b 或 --number-nonblank 和 -n 相似,只不过对于空白行不编号
-s 或 --squeeze-blank 当遇到有连续两行以上的空白行,就代换为一行的空白行
-n 或 --number 由 1 开始对所有输出的行数编号
-b 或 --number-nonblank 和 -n 相似,只不过对于空白行不编号
-s 或 --squeeze-blank 当遇到有连续两行以上的空白行,就代换为一行的空白行
-v 或 --show-nonprinting
例:cat test.txt
输出:
cc
dd
as
df
saf
2.从键盘创建一个文件。$ cat > filename
只能创建新文件,不能编辑已有文件.
dd
as
df
saf
2.从键盘创建一个文件。$ cat > filename
只能创建新文件,不能编辑已有文件.
[root@Slave2 test1]# cat test.txt
cc
saf
asdf
we
[root@Slave2 test1]# cat >test.txt
nn
mm
^C
[root@Slave2 test1]# cat test.txt
nn
mm
若文件名一样,就会覆盖原文件内容。
cc
saf
asdf
we
[root@Slave2 test1]# cat >test.txt
nn
mm
^C
[root@Slave2 test1]# cat test.txt
nn
mm
若文件名一样,就会覆盖原文件内容。
>> 是向文件中添加信息
[root@Slave2 test1]# echo ttt>>test.txt
[root@Slave2 test1]# cat test.txt
nn
mm
ttt
[root@Slave2 test1]# ^C
3.将几个文件合并为一个文件: $cat file1 file2 > file
[root@Slave2 test1]# cat test.txt
nn
mm
ttt
[root@Slave2 test1]# ^C
3.将几个文件合并为一个文件: $cat file1 file2 > file
[root@Slave2 test1]# cat a.txt
cc
dd
as
df
saf
[root@Slave2 test1]# cat test.txt
nn
mm
ttt
[root@Slave2 test1]# cat test1.txt
as
df
saf
[root@Slave2 test1]# cat test.txt test1.txt > a.txt
因为是>,源文件内容就消失了。
警告:我们要知道>意思是创建,>>是追加。千万不要弄混了。造成失误可不是闹着玩的;
[root@Slave2 test1]# cat a.txt
nn
mm
ttt
as
df
saf
[root@Slave2 test1]# echo qq >>test.txt
[root@Slave2 test1]# cat test.txt test1.txt >> a.txt
[root@Slave2 test1]# cat a.txt
nn
mm
ttt
as
df
saf
nn
mm
ttt
qq
as
df
saf
[root@Slave2 test1]# ^C
因为是>>,所以是追加操作,源文件的也会保留
1 0
- linux cat 命令详解
- linux cat 命令详解
- linux cat 命令详解
- linux cat 命令详解
- linux cat 命令详解
- linux cat 命令详解
- Linux cat命令详解
- linux cat 命令详解
- linux cat 命令详解
- Linux cat 命令详解
- linux cat 命令详解
- linux cat 命令详解
- linux cat命令详解
- linux cat 命令详解
- Linux cat命令详解
- linux 命令 cat 详解
- Linux cat命令详解
- Linux cat命令详解
- LeetCode-Q451-Sort Characters By Frequency
- HTML5摄像头拍照组件的封装
- 英文金曲大赛
- 在写ajax用encodeurlcomponent时出现问题
- Android 框架
- linux cat命令详解
- c++ primer plus
- 使用spring遇到"BeanNotOfRequiredTypeException......but was actually of type [com.sun.proxy.$Proxy18]"异常
- Hello World
- 一步一步使用Unity3d工具实现AR开发入门
- JavaScript中对象的深拷贝
- LeetCode406. Queue Reconstruction by Height
- LeetCode : Majority Element
- 名单真相