Linux命令列表:cat
cat用于附加文件或标准输入和打印。该命令经常用于显示一个文件的内容,或者连接多个文件进行显示,或者从标准输入读取内容并显示它们。通常与重定向符号结合使用。
1。命令格式
cat [选项] [文件]…
2.命令功能
cat有三个主要功能:
- 一次查看整个文件:
cat 文件名 - 从键盘创建文件:❙cat❙ 只有cat >❙可以创建新文件,无法编辑现有文件。
- 将多个文件合并为一个文件:
cat file1 file2 > file
命令参数:-A、❙-‷相当于 -vET- b、--number-nonblank,表示非空白输出行号-e-e❙♻❙♻❙♻❙♻ ♻ ,--显示结束在最后显示$-n, -, -‷每行的所有输出行开始from 1 -s,--squeeze-blank如果有两个以上连续空行,则将其替换为一行空行和❙♻相当于vt-t,tabs-show-tabsshow show跳跃字符在♝-v、--显示非打印使用^和M-❙,M-和TAB外侧
4.使用示例
示例一
将行号添加到文件 输出:mylog1.log 的内容中,然后在此文件中键入 mylog2.log。 的内容添加到行号后(不添加空行),将内容添加到
命令:
Shellcat -n mylog1.log mylog2.log
Shell[yiibai@localhost test]$ cat mylog1.log
this is line 1
this is line 2
[yiibai@localhost test]$ cat mylog2.log
log2 this is line 1
log2 this is line 2
log2 this is line 3
[yiibai@localhost test]$ cat -n mylog1.log mylog2.log
1 this is line 1
2 this is line 2
3 log2 this is line 1
4 log2 this is line 2
5 log2 this is line 3
[yiibai@localhost test]$
示例二❙❙ ’1❙。并将文件mylog2.log
log.log。
命令:
cat -b mylog1.log mylog2.log log.log
Shell输出:
yiibai@localhost test]$ cat -b mylog1.log mylog2.log >> log.log
[yiibai@localhost test]$ cat log.log
1 this is line 1
2 this is line 2
3 log2 this is line 1
4 log2 this is line 2
5 log2 this is line 3
[yiibai@localhost test]$
Shell示例三 此处使用
版权声明
本文仅代表作者观点,不代表Code前端网立场。
本文系作者Code前端网发表,如需转载,请注明页面地址。
code前端网