Friday, May 3, 2024
16
rated 0 times [  16] [ 0]  / answers: 1 / hits: 22020  / 1 Year ago, thu, december 8, 2022, 10:37:08

Is there a way to use wildcards with aptitude such as in the following:



sudo apt-get remove openoffice*.*

More From » command-line

 Answers
2

http://ubuntuforums.org/showthread.php?t=228309 indicates that it's possible via constructs such as ~n<package name> and this is confirmed by the user manual http://algebraicthunk.net/~dburrows/projects/aptitude/doc/en/ch02s03s02.html.



~n in ~n<package name> is a search pattern for matching package names. It's also possible to match other fields than packages' names, see http://algebraicthunk.net/~dburrows/projects/aptitude/doc/en/ch02s03s05.html#tableSearchTermQuickGuide.



Here's an example. Say that you want aptitude to show every package with "redshift" in its name, then you issue



aptitude show ~nredshift


It should be combinable with other aptitude options, such as install and remove, too, e.g. to remove all installed packages with openoffice in their name you issue



sudo aptitude -P remove ~nopenoffice


Make sure to use the -P option when using search patterns to force aptitude to display a prompt before downloading, installing or removing packages (the search pattern might have many matches and you'll want to be prompted before carrying out an action).



One thing that I haven't worked out is how to get the exact functionality of wildcards, e.g. that openoffice* matches every string starting with "openoffice" (~nopenoffice matches any string containing "openoffice"). Maybe a workaround is possible, e.g. to search for installed packages with a certain string in their names and then feed aptitude with their names.


[#43395] Friday, December 9, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
irtuallyefu

Total Points: 429
Total Questions: 97
Total Answers: 119

Location: Hong Kong
Member since Tue, Oct 19, 2021
3 Years ago
irtuallyefu questions
;