二十五岁时我们都一样愚蠢、多愁善感,喜欢故弄玄虚,可如果不那样的话,五十岁时也就不会如此明智。
标题:Linux shell cat 命令
Linux shell cat 命令用于连接文件并将内容输出到标准输出设备上。
使用权限
所有可用户
cat 命令语法格式
cat [-AbeEnstTuv] [--help] [--version] fileName参数
-n , --number :由 1 开始对所有输出的行数编号。
-b , --number-nonblank :和 -n 相似,只不过对于空白行不编号。
-s , --squeeze-blank :当遇到有连续两行以上的空白行,就代换为一行的空白行。
-v , --show-nonprinting :使用 ^ 和 M- 符号,除了 LFD 和 TAB 之外。
-E , --show-ends : 在每行结束处显示 $。
-T , --show-tabs : 将 TAB 字符显示为 ^I。
-e : 等价于 -vE。
-A, --show-all :等价于 -vET。
-e: 等价于"-vE"选项;
-t: 等价于"-vT"选项;
范例
将
demo1.txt
的文件内容加上行号后输出到demo2.txt
这个文件中
demo1.txt
文件内容[root@localhost ~]# cat demo1.txt Linux networks are becoming more and more common, but scurity is often an overlooked issue. Unfortunately, in today’s environment all networks are potential hacker targets, fro0m tp-secret military research networks to small home LANs. Linux Network Securty focuses on securing Linux in a networked environment, where the security of the entire network needs to be considered rather than just isolated machines. It uses a mix of theory and practicl techniques to teach administrators how to install and use security applications, as well as how the applcations work and why they are necesary.将
demo1.txt
的文件内容加上行号后输出到demo2.txt
这个文件[root@localhost ~]# cat -n demo1.txt > demo2.txt
demo2.txt
文件中的内容[root@localhost ~]# cat demo2.txt 1 Linux networks are becoming more and more common, but scurity is often an overlooked 2 issue. Unfortunately, in today’s environment all networks are potential hacker targets, 3 fro0m tp-secret military research networks to small home LANs. 4 Linux Network Securty focuses on securing Linux in a networked environment, where the 5 security of the entire network needs to be considered rather than just isolated machines. 6 It uses a mix of theory and practicl techniques to teach administrators how to install and 7 use security applications, as well as how the applcations work and why they are necesary. [root@localhost ~]#把文件
demo1.txt
和demo2.txt
的内容加上行号(空白行不加)之后将内容 附加 到demo3.txt
文件中:[root@localhost ~]# cat -b demo1.txt demo2.txt >> demo3.txt清空
/etc/test.txt
文件内容[root@localhost ~]# cat /dev/null > /etc/test.txtcat 也可以用来制作镜像文件
cat 命令可以制作软盘的镜像文件,将软盘放好后输入
[root@localhost ~]# cat /dev/fd0 > OUTFILE相反的,如果想把 image file 写到软盘,输入:
[root@localhost ~]# cat IMG_FILE > /dev/fd0注意
- OUTFILE 指输出的镜像文件名
- IMG_FILE 指镜像文件
- 若从镜像文件写回 device 时,device 容量需与相当
- 通常用制作开机磁片