grep

 

1.grep 或条件

[root@node2 nginx]# ps -ef|grep -e nginx -e PID
UID         PID   PPID  C STIME TTY          TIME CMD
root       5399      1  0 04:40 ?        00:00:00 nginx: master process ./nginx
nobody    11750   5399  0 05:49 ?        00:00:00 nginx: worker process
root      11781  11696  0 06:16 pts/0    00:00:00 grep -e nginx -e PID
[root@node2 nginx]# ps -aux|grep -e nginx -e %
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
USER        PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root       5399  0.0  0.0  23980  1324 ?        Ss   04:40   0:00 nginx: master process ./nginx
nobody    11750  0.0  0.0  24400  1624 ?        S    05:49   0:00 nginx: worker process
root      11783  0.0  0.0 103324   864 pts/0    S+   06:16   0:00 grep -e nginx -e %

  

同时,ps -ef可以看父进程ID  PPID  以及完整的command命令 CMD

    ps -aux 可以看进程的CPU占用率和内存占用率

 2.grep 忽略大小写

grep -i      i=ignore case

3.查找包含“***” 的所有的 .xml 文件

grep -R  --include“*。xml”’ “****”  ./

原文地址:https://www.cnblogs.com/jycjy/p/7944664.html