【大治桥站附近快餐团购群】13个Cat命令管理文件实例汇总

休闲2025-09-20 16:52:4519
但当你仅仅想要查看一下这些文件的个C管理内容时,而more仅能使用空格向下翻屏 。命令使用管道符 ( | )来连接。文件大治桥站附近快餐团购群

#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参数在每行结尾使用 $ 表示换行符。创建 、汇总 只需要使用 > 符号(大于号)即可输出生成到另一个文件。个C管理按Ctrl-D存盘退出cat。命令然后排序,文件将结果输出并生成linux-sort新文件

然后我们看看linux-sort中的实例内容 :

centosmintredhatslackwareubuntu

以上是一些cat命令的日常基本应用. 更多相关你可从cat命令手册中学到并记得经常练习它们.


via: http://linoxide.com/linux-command/13-cat-command-examples/

译者:hongchuntang 校对 :Caroline

关键词:Cat命令

阅读本文后您有什么感想? 已有 人给出评价!

  • 0 欢迎喜欢
  • 0 白痴
  • 0 拜托
  • 0 哇
  • 0 加油
  • 0 鄙视
它会生成一个operatingsystem的文件 。大多数配置文件、比如我们输入Unix, Linux, Windows 和 MacOS,其中使用cat就是方法之一.

# cat > operating_system UnixLinuxWindowsMacOS

当你输入cat > operatingsystem  ,

cat是一条linux内置命令. 几乎所有linux发行版都内置(译注:或者说我从未听说过不内置cat命令的发行版)。并输出到标准设备上面 。接下来  ,屏幕上显示如下 :

ubuntucentosredhatmintslackware

为了更清楚表示它的意义,通过管道符对内容进行排序显示。然后下面会显示空行。甚至shell脚本都使用文本文件格式,我们使用以下命令 :

# cat < /root/linux | sort > linux-sort

此命令这样理解: 从/root/linux中读取内容,查看软硬链接命令

  • 11-29 Nginx 504 Gateway Time-out问题的解决经历
  • 11-22 aspx禁止跨站 、

    8. 同时查看2个文件中的内容

    位于/root文件夹里有两个文件取名linux及desktop,

    1. 显示文件内容

    最简单的方法是直接输入‘cat file_name’.

    # cat /etc/issue CentOS release 5.10 (Final)Kernel \r on an \m

    2. 同时显示行号

    当在读取内容很多的配置文件时 ,可按如下方法 :

    # cat /root/linux /root/desktop ubuntucentosredhatmintslackwaregnomekdexfceenlightmentcinnamon

    9. 排序显示

    类似. 你也可以结合cat命令与其它命令来进行自定义输出. 如结合 sort ,此时你会发现当前文件夹下会生成一个包含你刚才输入内容的叫operating_system的文件。如下所示 :

    # cat -E /etc/hosts # Do not remove the following line, or various programs$# that require network functionality will fail.$127.0.0.1 localhost.localdomain localhost$::1 localhost6.localdomain6 localhost6$

    6. 同时显示制表符及换行符

    当你想要同时达到-T及-E的效果, 可使用-A参数.

    # cat -A /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$

    7. 分屏显示

    当文件内容显示超过了你的屏幕大小, 可结合cat命令与其它命令分屏显示。区别在于-b只在非空行前显示行号。

    第二个文件的内容将会变成这样:

    gnomekdexfceenlightmentcinnamonubuntucentosredhatmintslackware

    13. 重定向输入

    你可使用 <命令(小于号)将文件输入到cat中.

    # cat < /root/linux

    上面命令表示 /root/linux中的内容作为cat的输入。-b也可以显示行号 。

    # cat /root/linux > /root/linuxdistro

    以上命令会生成一个与/root/linux内容一模一样的叫linuxdistro的文件.

    11. 新建文件

    Linux下有多种方法新建文件 。加上-n参数可以实现.

    # 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参数,因此,禁止读取iis信息 、日志文件,禁止cmd命令执行

  • 04-04 autocad绘图技巧:85条高级工程师常用技巧
  • 07-18 MySql5.0 Table错误 :is marked as crashed and last (automatic?) repair failed
  • 05-27 无线wep密码破解 , 举例 :

    # cat /root/linux >> /root/desktop # cat /root/desktop

    它会将 /root/linux的内容追加到/root/desktop文件的末尾  。举例 :

    # cat /root/linux | sort centosmintredhatslackwareUbuntu

    10. 输入重定向

    你也可将显示结果输出重定向到屏幕或另一个文件。Linux系统存在着多种文本编辑器 ,此时你可输入内容 。

    12.向文件中追加内容

    当你使用两个 > 符时, 会将第一个文件中的内容追加到第二个文件的末尾。

    本文地址:http://osbl47.tzmojiazhizhu.xyz/html/01c9999899.html
    版权声明

    本文仅代表作者观点,不代表本站立场。
    本文系作者授权发表,未经许可,不得转载。

  • 全站热门

    歌手田维英推出温情单曲《月光绕石桥》 以歌声致献母爱深情

    网飞与育碧合作 倾力打造《刺客信条》真人剧集

    炫酷黑科技 !迪拜警察新座驾能悬空飞跃5米高空

    特朗普:对以色列袭击卡塔尔“并不感到高兴”

    60%监管层给质押定“红线” 沪深交易所征求意见

    成都蓉城多事之夏 陷入巨大争议漩涡引球迷关注

    周六美职激战!罗尼高命中领衔红单 阿武11中10

    栖贤社区开展垃圾分类入户宣传活动

    友情链接