我安装了两个版本的 Libre Office - 4.3 和默认版本:
dpkg --get-selections | grep -v deinstall | grep libreoffice
节目
libreoffice-avmedia-backend-gstreamer
libreoffice-base-core
libreoffice-calc
libreoffice-common
libreoffice-core
libreoffice-draw
libreoffice-help-en-gb
libreoffice-help-en-us
libreoffice-impress
libreoffice-l10n-en-gb
libreoffice-l10n-en-za
libreoffice-math
libreoffice-pdfimport
libreoffice-style-galaxy
libreoffice-writer
libreoffice4.3
libreoffice4.3-base
libreoffice4.3-calc
libreoffice4.3-debian-menus
libreoffice4.3-dict-en
libreoffice4.3-dict-es
libreoffice4.3-dict-fr
libreoffice4.3-draw
libreoffice4.3-en-us
libreoffice4.3-impress
libreoffice4.3-math
libreoffice4.3-ure
libreoffice4.3-writer
我只想要libreoffice4.3-*
,却不想要libreoffice^/(?!4.3)-*
有没有办法在命令中使用这种正则表达式apt-get
?
答案1
apt-get
接受 POSIX 正则表达式(不是 shell 样式的通配符):
sudo apt-get remove '^libreoffice4.3-*'
将删除
libreoffice4.3
libreoffice4.3-base
libreoffice4.3-calc
libreoffice4.3-debian-menus
libreoffice4.3-dict-en
libreoffice4.3-dict-es
libreoffice4.3-dict-fr
libreoffice4.3-draw
libreoffice4.3-en-us
libreoffice4.3-impress
libreoffice4.3-math
libreoffice4.3-ure
libreoffice4.3-writer
以及那些依赖它们的程序。(这就是为什么apt-get remove libreoffice4*
它没有按照你想象的那样运行。)
因此尝试一下:
sudo apt-get remove '^libreoffice-.*' libreoffice
这将删除:
libreoffice-avmedia-backend-gstreamer
libreoffice-base-core
libreoffice-calc
libreoffice-common
libreoffice-core
libreoffice-draw
libreoffice-help-en-gb
libreoffice-help-en-us
libreoffice-impress
libreoffice-l10n-en-gb
libreoffice-l10n-en-za
libreoffice-math
libreoffice-pdfimport
libreoffice-style-galaxy
libreoffice-writer
libreoffice
If no package matches the given expression and the expression
contains one of '.', '?' or '*' then it is assumed to be a POSIX
regular expression, and it is applied to all package names in the
database. Any matches are then installed (or removed). Note that
matching is done by substring so 'lo.*' matches 'how-lo' and
'lowest'. If this is undesired, anchor the regular expression with
a '^' or '$' character, or create a more specific regular
expression.