Cat is a text file viewing and linking tool, if you want to view all the contents of a file, it is convenient to use cat + file name
1、cat 用来查看文件内容。 如:[[email protected] home]# cat test01 Hello World!2、cat的一些常用用法。 -A, (--show-all 会把有空行的和转行末尾加个 $ 显示出来)如: [[email protected] home]# cat -A test01 12346789$ 123456789$ 123$ $ 456$ $ 789$ -b,( --number-nonblank 对非空输出行编号) [[email protected] home]# cat -b test01 1 12346789 2 123456789 3 123 4 456 5 789 -e (--show-ends 在每行结束处显示 $) -E, (--show-ends 在每行结束处显示 $) -n,( --number 对输出的所有行编号) -s, (--squeeze-blank 不输出多行空行) -t ,(-T, --show-tabs 将跳 字符显示为 ^I) -u 跟直接cat + 查询文件名 ,效果一样如:[[email protected] home]# cat -u test01 效果跟 cat test01一样 12346789 123456789 123 456 789 --help (显示此帮助信息并离开)如:[[email protected] home]# cat --help
2, Cat has the ability to create files, after creating the file, to end with EOF or stop
[Email protected] home]# cat>a.txt >>eof Note: Create a a.txt file;
Hello world! Note: This is the writing to the A.txt file;
EOF Note: Exit edit State;
[email protected] home]# Cat a.txt Note: View the contents of A.txt
Tip: Cat can also append content to a file that already exists
3.cat connect the contents of multiple files and output to a new file;
There are a.txt, B.tx and C.txt, and the contents are as follows;
[email protected] home]# cat A.txt
Hello
Love
I am testing
[[email protected] home]# cat B.txt world! China Beinan tested [[email protected] Home ]# Cat C.txt I am Chinese. If the three file contents of A.txt, B.txt and C.txt are connected and exported to a new file D.txt, then we can use Cat Note: The principle is to connect the contents of three files, then create the D.txt file, and write the connected content simultaneously The D.txt. Tip: If you want to enter a D.txt file that is an already existing content, this will erase the contents of the D.txt (that is, the content is just a concatenation of the contents of the A,b,c.txt file). [[email protected] home]# cat a.txt b.txt c.txt > d.txt[[email protected] home]# cat D.txt Hello Love I am testi Ng world! China Beinan tested I am Chinese.
If you use cat to append one or more existing file contents to an existing file
[email protected] home]# cat E.txt
I Love Chia.
[[email protected] home]# cat a.txt b.txt c.txt >> e.txt[[email protected] home]# t e.txt I love Chia. Hello love i am testing World! China BeiNan Tested I am Chinese.
Note: Through the above, we want to understand:
是创建
> is an additional
Don't get mixed up.
----------------------------祝大家学习愉快!---------------------------
Linux Cat Usage Moe New learning Path (1)