![grep yum 指令輸出中以 - 或加號開頭的行](https://rvso.com/image/168790/grep%20yum%20%E6%8C%87%E4%BB%A4%E8%BC%B8%E5%87%BA%E4%B8%AD%E4%BB%A5%20-%20%E6%88%96%E5%8A%A0%E8%99%9F%E9%96%8B%E9%A0%AD%E7%9A%84%E8%A1%8C.png)
我正在運行 yum 查詢
yum group info 'X Window System'
輸出如下
yum group info 'X Window System'
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.vanehost.com
* extras: mirror.vanehost.com
* updates: mirror.vanehost.com
Group: X Window System
Group-Id: x11
Description: X Window System Support.
Mandatory Packages:
-glx-utils
-initial-setup-gui
=mesa-dri-drivers
=plymouth-system-theme
=spice-vdagent
+xorg-x11-drivers
=xorg-x11-server-Xorg
=xorg-x11-utils
=xorg-x11-xauth
=xorg-x11-xinit
=xvattr
Optional Packages:
mesa-libGLES
tigervnc-server
wayland-protocols-devel
xorg-x11-drv-evdev
xorg-x11-drv-keyboard
xorg-x11-drv-libinput
xorg-x11-drv-mouse
xorg-x11-drv-openchrome
但是當我對此運行 grep 來過濾掉以 - 或 + 開頭的行時
yum group info 'X Window System' | grep -E "^[-+]"
我得到一個空白輸出。有人可以讓我知道我哪裡出了問題嗎?
答案1
這些行不以+
或開頭-
,而是以空格開頭。嘗試
grep -E "^[[:blank:]]*[-+]"