zoukankan      html  css  js  c++  java
  • cat命令汇总整理

    Cat命令:一般用作打开文件,查看文件内容(可以一次查看多个文件),参数有如下几个:

           -a 或 –all,显示全部

           -b 或--number-nonblank 对非空输出行编号

      -n 或 --number 由 1 开始对所有输出的行数编号
      -s 或 --squeeze-blank 当遇到有连续两行以上的空白行,就代换为一行的空白行

    A.用于查看文件内容cat blank.txt     查看名为blank的txt文件内容;

    B.用于创建新的文件并输入内容cat > filename <<EOF,enter后输入文件内容,结尾处<<EOF结束;

    C . 将几个文件合为一个文件cat filename1 filename2 filename3 > newfilename  ,举例如下:<cat还可以把一个或多个已存在的文件内容,追加到一个已存在的文件中

      cat s01  s02  s03 >> sA’>’意思是创建,’>>’是追加,不要记错>

    A例.[root@localhost ~]# cat -n initial-setup-ks.cfg original-ks.cfg

         1   #version=DEVEL

         2   # Install OS instead of upgrade

         3   install

         4   # X Window System configuration information

         5   xconfig  --startxonboot

     B例.[root@localhost ~]# cat > 123 << EOF #新建一个以123命名的文件

        > hallo world

        > how are you

        > i am  fine

        > EOF     

      [root@localhost ~]# cat 123

      hallo world

      how are you

      i am  fine

      [root@localhost ~]# cat >> 123

      i am very hot,how about you ?

      ^C

      [root@localhost ~]# cat 123

      hallo world

      how are you

      i am  fine

      i am very hot,how about you ? 已经累加到目标文件

     

    C例.[root@localhost ~]# cat > 123 #新建3份文件,分别为123、abc、EFG,并为各文件输入内容 

        this is the frist file^C

      [root@localhost ~]# cat > abc

        the second file is setting now^C

      [root@localhost ~]# cat > EFG

        the last one ^C

      [root@localhost ~]# ls -a

        . 123  anaconda-ks.cfg  .bash_logout   .bashrc  .config  .dbus  initial-setup-ks.cfg  original-ks.cfg  .xauth7xzQQg

        ..  abc  .bash_history    .bash_profile  .cache   .cshrc   EFG    mongodb_simple        .tcshrc

      [root@localhost ~]# cat 123 abc EFG > newone

      [root@localhost ~]# ls -a   #查看目录时,目标文件已经存在,

        .   123  anaconda-ks.cfg  .bash_logout   .bashrc  .config  .dbus  initial-setup-ks.cfg  newone #目标文件夹   .tcshrc

        ..  abc  .bash_history    .bash_profile  .cache   .cshrc   EFG    mongodb_simple        original-ks.cfg  .xauth7xzQQg

  • 相关阅读:
    React Native配置和使用
    使用ES6语法重构React代码
    git 起点
    Win32API程序中自建按钮
    C语言中数组与指针
    我的第一个博客
    Solr6.5配置中文分词IKAnalyzer和拼音分词pinyinAnalyzer (二)
    Solr6.5在Centos6上的安装与配置 (一)
    PHP版微信公共平台消息主动推送,突破订阅号一天只能发送一条信息限制
    MariaDB+Keepalived双主高可用配置MySQL-HA
  • 原文地址:https://www.cnblogs.com/bryant-dai/p/7419296.html
Copyright © 2011-2022 走看看