linux命令第三天-cat

cat 查看文件

man cat

cat --help

 

 Usage: cat [OPTION]... [FILE]...
 Concatenate FILE(s), or standard input, to standard output.
 ​
   -A, --show-all           equivalent to -vET
   -b, --number-nonblank    number nonempty output lines, overrides -n
   -e                       equivalent to -vE
   -E, --show-ends          display $ at end of each line
   -n, --number             number all output lines
   -s, --squeeze-blank      suppress repeated empty output lines
   -t                       equivalent to -vT
   -T, --show-tabs          display TAB characters as ^I
   -u                       (ignored)
   -v, --show-nonprinting   use ^ and M- notation, except for LFD and TAB
       --help     display this help and exit
       --version  output version information and exit
 ​
 With no FILE, or when FILE is -, read standard input.
 ​
 Examples:
   cat f - g  Output f's contents, then standard input, then g's contents.
   cat        Copy standard input to standard output.
 ​
 GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
 For complete documentation, run: info coreutils 'cat invocation'
 ​

构造一个cat.txt文件 具体内容如下

 first line
     two line
 third line
     tab line
 ​

 end line
 ​
 ​
 ​

目录

cat 查看文件

man cat

cat --help

构造一个cat.txt文件 具体内容如下


cat cat.txt

 [root@pdemo cat-test]# cat cat.txt 
 first line
     two line
 third line
     tab line
 ​
 end line
 ​
 ​

-A 看所有的tab 结尾等 相当于 -vET

 [root@pdemo cat-test]# cat -A cat.txt 
 first line$
     two line$
 third line$
 ^Itab line$
 $
 end line$
 ​
 ​
 ​
 说明:
 $表示结尾
 ^I 表示tab
 ​

-b 显示行数

 cat -b cat.txt
      1  first line
      2      two line
      3  third line
      4      tab line
 ​
      5  end line
 ​
 -b 会忽略空行

-n 打印行数 和 -b 很相似 只是在空行上有区别

 [root@pdemo cat-test]# cat -n cat.txt 
      1  first line
      2      two line
      3  third line
      4      tab line
      5  
      6  end line
 ​
 -n 不会忽略空行,空行也会算一行
 ​

 

-E 打印结尾的$

 [root@pdemo cat-test]# cat -E cat.txt 
 first line$
     two line$
 third line$
     tab line$
 $
 end line$
 ​
 ​
 结尾 会加上$

 

-s 多行空行会作为一行空行来显示

 [root@pdemo cat-test]# cat cat.txt.bak 
 first line
     two line
 third line
     tab line
 ​
 ​
 ​
 ​
 end line
 [root@pdemo cat-test]# 
 [root@pdemo cat-test]# cat -s cat.txt.bak
 first line
     two line
 third line
     tab line
 ​
 end line
 ​
 对比上面 就可以看出-s 选项只输出一个空格
 ​

 

-T 查看tab 使用^I 表示

 [root@pdemo cat-test]# cat -T cat.txt
 first line
     two line
 third line
 ^Itab line
 ​
 end line
 ​
 ​

 

cat f - g 输出f文件的内容 标准输入 然后再输出g文件的内容

 [root@pdemo cat-test]# cat cat.txt - cat.txt.bak 
 first line
     two line
 third line
     tab line
 ​
 end line
 ​
 ​
 ​
 ​
 dfd
 dfd
 fdf
 fdf
 dfd
 dfd
 first line
     two line
 third line
     tab line
 ​
 ​
 ​
 ​
 end line
 ​

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值