Linux的cat命令详解

The cat command reads one or more files and copies them to standard output
也就是说,cat命令读取文件,并显示在 standard output 中。正常情况下,也就是显示在屏幕上。

cat 的另一个功能是 concatenate, 连接。如下面这条命令:

 cat movie.mpeg.0* > movie.mpeg

将多个子mpeg文件合成为 movie.mpeg 文件。

如果输入 cat 不带参数:

cat

将从 standard input (如键盘)中读入,直到按 Ctrl+d 来为作 EOF。读入的信息同样将显示在standard output 上。

如果用以下命令:

cat filename.txt

从 standard input 读入的信息将被保存在 filename.txt 中。

使用如下命令:

cat < filename.txt

则 shell 将从 filename.txt 中读取信息,并显示在 standard output 上。

参考文献
Shotts Jr, W. E. (2012). The linux command line: A complete introduction. No Starch Press.

原文地址:https://www.cnblogs.com/yaos/p/14014459.html