Marco Nie - cat https://blog.niekun.net/tag/cat/ zh-CN Mon, 18 Nov 2019 21:48:00 +0800 Mon, 18 Nov 2019 21:48:00 +0800 cat 命令 in Linux https://blog.niekun.net/archives/534.html https://blog.niekun.net/archives/534.html Mon, 18 Nov 2019 21:48:00 +0800 admin 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
]]>
0 https://blog.niekun.net/archives/534.html#comments https://blog.niekun.net/feed/tag/cat/archives/534.html