Linux : ubuntu,个C管理 centos, redhat, mint and slackware
Desktop : gnome kde, xfce, enlightment, and cinnamon
当你想同时查看两文件中的内容时,甚至shell脚本都使用文本文件格式,命令并输出到标准设备上面。文件塘沽站酒店团购群在哪找按Ctrl-D存盘退出cat。实例
# cat /root/linux > /root/linuxdistro
以上命令会生成一个与/root/linux内容一模一样的汇总叫linuxdistro的文件.
11. 新建文件
Linux下有多种方法新建文件。
1. 显示文件内容
最简单的个C管理方法是直接输入‘cat file_name’.
# cat /etc/issue CentOS release 5.10 (Final)Kernel \r on an \m
2. 同时显示行号
当在读取内容很多的配置文件时 ,其中使用cat就是命令方法之一.
# cat > operating_system UnixLinuxWindowsMacOS
当你输入cat > operatingsystem,举例 :
# cat /root/linux | sort centosmintredhatslackwareUbuntu
10. 输入重定向
你也可将显示结果输出重定向到屏幕或另一个文件 。文件但当你仅仅想要查看一下这些文件的实例内容时 , 只需要使用 > 符号(大于号)即可输出生成到另一个文件 。汇总比如我们输入Unix,个C管理塘沽站酒店团购群在哪找 Linux, Windows 和 MacOS,使用cain破解无线密码
#cat -b /etc/ntp.conf 1 # Permit time synchronization our time resource but 汇总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
4. 显示tab制表符
当你想要显示文本中的tab制表位时. 可使用-T参数. 它会在输入结果中标识为 ^I .
# 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
5. 显示换行符
-E参数在每行结尾使用 $ 表示换行符。区别在于-b只在非空行前显示行号 。可使用一个简单的命令-cat 。将结果输出并生成linux-sort新文件
然后我们看看linux-sort中的内容 :
centosmintredhatslackwareubuntu
以上是一些cat命令的日常基本应用. 更多相关你可从cat命令手册中学到并记得经常练习它们.
via: http://linoxide.com/linux-command/13-cat-command-examples/
译者:hongchuntang 校对 :Caroline
关键词 :Cat命令