linux中cat的用法
1.显示文件内容 直接 cat filename# cat file2
this is a test of cat
this file's name is file2
2.显示文件内容,对非空白行编码 cat -b filenme
# cat -b file1
1this is for test of cat
2this filename is file1
3last line
3.对于比较大的文件,可以采用 cat filename |more
4.创建文件cat >newfilename<<EOF
# cat >file5<<EOF
> KNOWLEDGE IS POWER
这个例子创建了一个file5的文件,并提示要写入的内容,直到遇到EOF(linux下面的EOF是通过ctrl+d输入的)。
5.向已有的文件中增加内容 cat>>existingfile<<EOF
# cat>>file5<<EOF
> this a new content added
同样EOF结束输入。
6.将几个文件联结输入到一个新文件 catfilename1 filename2>filename3
7.将几个文件联结追加到一个现有的文件中 cat filenam1 filename2 >>filename3
1. cat 接普通文件名,会把文件内容打印到屏幕;
2. cat > file,这个可以向文件“file”写入内容,最后按 Ctrl + D 结束输入,会将你输入的数据保存到文件。
页:
[1]