cat 查看文件
man cat
cat --help
Usage: cat [OPTION]... [FILE]... Concatenate FILE(s), or standard input, to standard output. -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 With no FILE, or when FILE is -, read standard input. 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: <http://www.gnu.org/software/coreutils/> For complete documentation, run: info coreutils 'cat invocation'
构造一个cat.txt文件 具体内容如下
first line two line third line tab line
end line
目录
cat cat.txt
[root@pdemo cat-test]# cat cat.txt first line two line third line tab line end line
-A 看所有的tab 结尾等 相当于 -vET
[root@pdemo cat-test]# cat -A cat.txt first line$ two line$ third line$ ^Itab line$ $ end line$ 说明: $表示结尾 ^I 表示tab
-b 显示行数
cat -b cat.txt 1 first line 2 two line 3 third line 4 tab line 5 end line -b 会忽略空行
-n 打印行数 和 -b 很相似 只是在空行上有区别
[root@pdemo cat-test]# cat -n cat.txt 1 first line 2 two line 3 third line 4 tab line 5 6 end line -n 不会忽略空行,空行也会算一行
-E 打印结尾的$
[root@pdemo cat-test]# cat -E cat.txt first line$ two line$ third line$ tab line$ $ end line$ 结尾 会加上$
-s 多行空行会作为一行空行来显示
[root@pdemo cat-test]# cat cat.txt.bak first line two line third line tab line end line [root@pdemo cat-test]# [root@pdemo cat-test]# cat -s cat.txt.bak first line two line third line tab line end line 对比上面 就可以看出-s 选项只输出一个空格
-T 查看tab 使用^I 表示
[root@pdemo cat-test]# cat -T cat.txt first line two line third line ^Itab line end line
cat f - g 输出f文件的内容 标准输入 然后再输出g文件的内容
[root@pdemo cat-test]# cat cat.txt - cat.txt.bak first line two line third line tab line end line dfd dfd fdf fdf dfd dfd first line two line third line tab line end line