On 7/27/20 12:23 AM, Todd Zullinger wrote:
Refer to the "SPECIFYING PACKAGES" section in the dnf man page. It explains the syntax options you can use to specify a <package-spec>, which is used by many dnf commands, like dnf remove.
The doc is all good but without some real examples I find it difficult to translate the doc to actual commands.
But that's probably because I am a noob and not use to reading docs seriously yet.
Perhaps this is a minor point, but it's good to get in the habit of escaping shell wildcard characters, like '*' in the above command.
I didn't know that. I will do that from now on, thanks.
As you'll find in the man page, dnf accepts glob patterns, which are much like shell glob patterns. You can use them to remove all 5.7 kernels, something like:
$ sudo dnf remove 'kernel*-5.7.*'
Would this have had the same effect as:
sudo dnf remove $(rpm -qa | grep ^kernel | grep 5.7)
??
Similarly, you can use the patterns to avoid the need for the pipe to grep above (which also didn't need the -i option, as your argument is numeric):
$ sudo dnf list installed 'kernel*-5.7.*'
Yeah I tried this but this does not give the name of the packages in a way I can use in 'dnf remove' command, thus it was not very helpful.