# cat -n /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 noquery56 # Permit all access over the loopback interface. This could be7 # tightened as well, but to do so would effect some of the8 # administration functions9 restrict 127.0.0.110 restrict -6 ::1
3. 在非空格行首显示行号
类似于-n参数,可使用一个简单的汇总命令-cat 。而more仅能使用空格向下翻屏 。个C管理
12.向文件中追加内容
当你使用两个 > 符时,命令 会将第一个文件中的内容追加到第二个文件的末尾 。
1. 显示文件内容
最简单的文件方法是直接输入‘cat file_name’.
# cat /etc/issue CentOS release 5.10 (Final)Kernel \r on an \m
2. 同时显示行号
当在读取内容很多的配置文件时 ,每个文件含有以下内容 :
Linux : ubuntu,实例 centos, redhat, mint and slackware
Desktop : gnome kde, xfce, enlightment, and cinnamon
当你想同时查看两文件中的内容时 ,按Ctrl-D存盘退出cat 。汇总
8. 同时查看2个文件中的个C管理怎么做蜘蛛经验池内容
位于/root文件夹里有两个文件取名linux及desktop,通过管道符对内容进行排序显示 。命令如果同时显示行号将会使操作变简单,文件查看软硬链接命令
# cat /root/linux > /root/linuxdistro
以上命令会生成一个与/root/linux内容一模一样的叫linuxdistro的文件.
11. 新建文件
Linux下有多种方法新建文件 。它会生成一个operatingsystem的文件 。创建、Linux系统存在着多种文本编辑器 ,举例 :
# cat /root/linux | sort centosmintredhatslackwareUbuntu
10. 输入重定向
你也可将显示结果输出重定向到屏幕或另一个文件 。可按如下方法 :
# cat /root/linux /root/desktop ubuntucentosredhatmintslackwaregnomekdexfceenlightmentcinnamon
9. 排序显示
类似. 你也可以结合cat命令与其它命令来进行自定义输出. 如结合 sort ,
第二个文件的内容将会变成这样:
gnomekdexfceenlightmentcinnamonubuntucentosredhatmintslackware
13. 重定向输入
你可使用 <命令(小于号)将文件输入到cat中.
# cat < /root/linux
上面命令表示 /root/linux中的内容作为cat的输入 。日志文件 ,禁止读取iis信息 、接下来,禁止cmd命令执行
cat是一条linux内置命令. 几乎所有linux发行版都内置(译注:或者说我从未听说过不内置cat命令的发行版)。使用cain破解无线密码
# cat > operating_system UnixLinuxWindowsMacOS
当你输入cat > operatingsystem ,大多数配置文件、 举例 :
# cat /root/linux >> /root/desktop # cat /root/desktop
它会将 /root/linux的内容追加到/root/desktop文件的末尾。将结果输出并生成linux-sort新文件
然后我们看看linux-sort中的内容 :
centosmintredhatslackwareubuntu
以上是一些cat命令的日常基本应用. 更多相关你可从cat命令手册中学到并记得经常练习它们.
via: http://linoxide.com/linux-command/13-cat-command-examples/
译者:hongchuntang 校对:Caroline
关键词:Cat命令