linux命令cat的介绍和使用案例

韵味老鸟 2024-08-29 13:53:07

linux 命令 cat 的介绍和使用案例

cat 命令是 Linux 中一个非常基础且实用的命令,主要用于查看和处理文本文件的内容。它的名字来源于“concatenate”,意为连接

命令介绍基本语法bashcat [OPTION] [FILE...]OPTION:可选参数,用于修改 cat 命令的默认行为。FILE:一个或多个要处理的文件名。如果没有指定文件,cat 将从标准输入读取内容。常用选项-n:为所有输出行编号。-b:仅对非空行编号。-s:压缩连续的空白行,只显示一行空白行。-E:在每行的末尾显示 $ 符号。-T:将制表符显示为 ^I。-v:显示不可打印字符。

命令功能:

root@meng:~# which cat

/usr/bin/cat

root@meng:~# cat --help

Usage: cat [OPTION]... [FILE]...

Concatenate FILE(s) to standard output.

With no FILE, or when FILE is -, read standard input.

-A, --show-all equivalent to -vET

-b, --number-nonblank number nonempty output lines, overrides -n

-e equivalent to -vE

-E, --show-ends display $ at end of each line

-n, --number number all output lines

-s, --squeeze-blank suppress repeated empty output lines

-t equivalent to -vT

-T, --show-tabs display TAB characters as ^I

-u (ignored)

-v, --show-nonprinting use ^ and M- notation, except for LFD and TAB

--help display this help and exit

--version output version information and exit

Examples:

cat f - g Output f's contents, then standard input, then g's contents.

cat Copy standard input to standard output.

GNU coreutils online help: <https://www.gnu.org/software/coreutils/>

Report any translation bugs to <https://translationproject.org/team/>

Full documentation <https://www.gnu.org/software/coreutils/cat>

or available locally via: info '(coreutils) cat invocation'

root@meng:~# cat

命令案例:

root@meng:~# cat

ls

ls

whoami

whoami

this is a cat^[[6~

this is a cat

root@meng:~# cat f1.txt.bz2

BZh91AY&SYʗbǐ !aw$S

6/ root@meng:~#

root@meng:~#

root@meng:~#

root@meng:~# cat rec00001f1.txt

f1

root@meng:~# cat f1.txt.bz2 rec00001f1.txt > meng.txt

root@meng:~# cat meng.txt

BZh91AY&SYʗbǐ !aw$S

6/ f1

0 阅读:6

韵味老鸟

简介:感谢大家的关注