grep -E '123|abc' filename // 找出文件(filename)中包含123或者包含abc的行
egrep '123|abc' filename //用egrep同样可以实现
awk '/123|abc/' filename // awk 的实现方式
0
本帖最后由 lyhabc 于 2016-2-14 18:11 编辑
awk '/123/ || /abc/ {print}' 11.txt
grep -E "abc|123" 11.txt
awk '/123/ && /abc/ {print}' 11.txt
awk '/123/ || /abc/ {print}' 11.txt
grep -E "abc|123" 11.txt
awk '/123/ && /abc/ {print}' 11.txt
0
root bin daemon adm lp sync shutdown halt mail operator games ftp nobody systemd-bus-proxy systemd-network dbus polkitd tss sshd postfix chrony ntp nscd tcpdump
root bin daemon adm lp sync shutdown halt mail operator games FTP User Nobody systemd Bus Proxy systemd Network Management System message bus User for polkitd Account used by the trousers package to sandbox the tcsd daemon Privilege-separated SSH NSCD Daemon
sed表示同样可以
[root@aiker02 ~]# sed -n '/[root|mail]/'p test2.txt
root bin daemon adm lp sync shutdown halt mail operator games ftp nobody systemd-bus-proxy systemd-network dbus polkitd tss sshd postfix chrony ntp nscd tcpdump
root bin daemon adm lp sync shutdown halt mail operator games FTP User Nobody systemd Bus Proxy systemd Network Management System message bus User for polkitd Account used by the trousers package to sandbox the tcsd daemon Privilege-separated SSH NSCD Daemon
编辑回复