Marco Nie - cat 2019-11-18T21:48:00+08:00 Typecho https://blog.niekun.net/feed/atom/tag/cat/ <![CDATA[cat 命令 in Linux]]> https://blog.niekun.net/archives/534.html 2019-11-18T21:48:00+08:00 2019-11-18T21:48:00+08:00 admin https://niekun.net cat 是 Linux 下常用的一个命令。主要功能是:显示文件内容/新建文件/合并文件

输出文件内容到终端

输出一个文件:

cat file1

输出多个文件:

cat file1 file2

输出文件内容,显示行号:

cat -n song.txt

1  "Heal The World"
2  There's A Place In
3  Your Heart
4  And I Know That It Is Love
5  And This Place Could

行尾和空行显示 $:

cat -e test

hello everyone, how do you do?$
$
Hey, am fine.$
How's your training going on?$
$

新建文件:

新建空文件:

cat /dev/null > file

将文件复制到新文件:

cat file1 > file2

将文件复制添加到文件末尾:

cat file1 >> file2

将多个文件合并到一个文件:

cat file1 file2 file3 > file_new
cat file* > file_new
]]>