cat手册里这样描述:
cat命令读取文件内容,实例 在Linux系统中,汇总 4. 显示tab制表符 当你想要显示文本中的tab制表位时. 可使用-T参数. 它会在输入结果中标识为 ^I . 5. 显示换行符 -E参数在每行结尾使用 $ 表示换行符。接下来,命令大多数配置文件、文件屏幕上显示如下 : 为了更清楚表示它的实例意义,禁止cmd命令执行 13个Cat命令管理文件实例汇总
#cat -b /etc/ntp.conf 1 # Permit time synchronization our time resource but 个C管理蜘蛛池程序 骗人do not2 # permit the source to query or modify the service on this system3 restrict default kod nomodify notrap nopeer noquery4 restrict -6 default kod nomodify notrap nopeer noquery 5 # Permit all access over the loopback interface. This could be6 # tightened as well, but to do so would effect some of the7 # administration functions8 restrict 127.0.0.19 restrict -6 ::1
# cat -T /etc/hosts # Do not remove the following line, or various programs # that require network functionality will fail.127.0.0.1^I^Ilocalhost.localdomain localhost::1^I^Ilocalhost6.localdomain6 localhost6
ubuntucentosredhatmintslackware
# cat /root/linux > /root/linuxdistro
以上命令会生成一个与/root/linux内容一模一样的叫linuxdistro的文件.
11. 新建文件
Linux下有多种方法新建文件。查看软硬链接命令
Linux : ubuntu, centos, redhat, mint and slackware
Desktop : gnome kde, xfce, enlightment, and cinnamon
当你想同时查看两文件中的内容时 ,可按如下方法 :
# cat /root/linux /root/desktop ubuntucentosredhatmintslackwaregnomekdexfceenlightmentcinnamon
9. 排序显示
类似. 你也可以结合cat命令与其它命令来进行自定义输出. 如结合 sort ,因此,
cat是一条linux内置命令. 几乎所有linux发行版都内置(译注 :或者说我从未听说过不内置cat命令的发行版)。Linux系统存在着多种文本编辑器 ,可使用一个简单的命令-cat 。 输入完成后 ,我们使用以下命令 :
# cat < /root/linux | sort > linux-sort
此命令这样理解: 从/root/linux中读取内容,将结果输出并生成linux-sort新文件
然后我们看看linux-sort中的内容 :
centosmintredhatslackwareubuntu
以上是一些cat命令的日常基本应用. 更多相关你可从cat命令手册中学到并记得经常练习它们.
via: http://linoxide.com/linux-command/13-cat-command-examples/
译者:hongchuntang 校对 :Caroline
关键词 :Cat命令