Linux-cat命令

命令讲解:

cat主要有三大功能:

1.一次显示整个文件:cat filename

2.从键盘创建一个文件:cat > filename 只能创建新文件,不能编辑已有文件.

3.将几个文件合并为一个文件:cat file1 file2 > file

实操验证:

[154.8.159.209:root@xlp117 /var/www/html/log]# cat sms_status_pdd.log.2020-03-18
---
2020-3-18 14:08:55
POST /pdd/sms/status?appid=1400155389
[{"mobile":"13126593380","report_status":"SUCCESS","description":"用户短信接收成功","errmsg":"DELIVRD","user_receive_time":"2019-11-09 00:00:01","sid":"98:6014940","nationcode":"86"}]
POST http://10.30.30.74:18098/xlp/cmpp?action=receiveSmsStatus&spcode=100000&msgfmt=8 - 22ms
[{"sid":"","uid":"","user_receive_time":"2019-11-09 00:00:01","error_msg":"DELIVRD","mobile":"13126593380","report_status":"SUCCESS","original":null}]
200
{"msg":"notfound","errorcode":"-1"}
---
2020-3-18 14:27:11
POST /pdd/sms/status?appid=1400155389
[{"mobile":"13126593380","report_status":"SUCCESS","description":"用户短信接收成功","errmsg":"DELIVRD","user_receive_time":"2019-11-09 00:00:01","sid":"5031259","nationcode":"86"}]
POST http://10.30.30.74:18098/xlp/cmpp?action=receiveSmsStatus&spcode=100000&msgfmt=8 - 19ms
[{"sid":"1494363028144520720","uid":"","user_receive_time":"2019-11-09 00:00:01","error_msg":"DELIVRD","mobile":"13126593380","report_status":"SUCCESS","original":null}]
200
{"msg":"notfound","errorcode":"-1"}
---------------------------------------------------------------------------
[154.8.159.209:root@xlp117 /home/wangzn209]# cat > filename.txt
hello
^C
[154.8.159.209:root@xlp117 /home/wangzn209]# ls
filename.txt
[154.8.159.209:root@xlp117 /home/wangzn209]# cat filename.txt
hello
[154.8.159.209:root@xlp117 /home/wangzn209]# cat >file1
001
^C
[154.8.159.209:root@xlp117 /home/wangzn209]# cat >file2
002
^C
[154.8.159.209:root@xlp117 /home/wangzn209]# ls
file1 file2 filename.txt
---------------------------------------------------------------------------
[154.8.159.209:root@xlp117 /home/wangzn209]# cat file1 file2 > file
[154.8.159.209:root@xlp117 /home/wangzn209]# ls
file file1 file2 filename.txt
[154.8.159.209:root@xlp117 /home/wangzn209]# cat file
001
002

原文地址:https://www.cnblogs.com/wangzn/p/12564922.html