Linux维护-CAT命令基础

来源:互联网 发布:淘宝上的川味小吃店铺 编辑:程序博客网 时间:2024/06/14 14:33

语法:

[root@vm1 tmp]# 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
  -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.


Report cat bugs to bug-coreutils@gnu.org
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
For complete documentation, run: info coreutils 'cat invocation'
[root@vm1 tmp]# 


示例:

[root@vm1 tmp]# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
jps:x:500:500:jiapeisi1:/home/jps:/bin/bash
www:x:501:501::/home/www:/bin/bash
mysql:x:502:502::/home/mysql:/bin/bash


[root@vm1 tmp]# cat /etc/group
root:x:0:root
bin:x:1:root,bin,daemon
jps:x:500:
www:x:501:
mysql:x:502:


[root@vm1 tmp]# cat /etc/passwd | grep mysql
mysql:x:502:502::/home/mysql:/bin/bash


[root@vm1 tmp]# cat /etc/passwd | grep -v mysql
root:x:0:0:root:/root:/bin/bash
sync:x:5:0:sync:/sbin:/bin/sync
jps:x:500:500:jiapeisi1:/home/jps:/bin/bash
www:x:501:501::/home/www:/bin/bash
mailman:x:41:41:GNU Mailing List Manager:/usr/lib/mailman:/sbin/nologin
nagios:x:503:503::/home/nagios:/bin/bash

[root@vm1 tmp]# cat /etc/passwd|grep -v nologin|grep -v halt|grep -v shutdown|awk -F":" '{ print $1"|"$3"|"$4 }'|more
root|0|0
sync|5|0
jps|500|500
www|501|501
mysql|502|502
nagios|503|503


[root@vm1 tmp]# cat /etc/passwd|awk -F":" '{ print $1 }'|more
root
bin
jps
www
mysql



0 0
原创粉丝点击