> On 23 May 2022, at 23:03, Todd Zullinger <t...@pobox.com> wrote:
> 
> Hi,
> 
> Bill Cunningham wrote:
>> I have been trying to use rpm or dnf to remove some rpms.
> 
> I'd use dnf.  It provides a much wider safety net.

I have always assumed that using rpm -e will mess up dnf.
so I never use rpm for any operation that modifies the system.
I think I shot off a foot a decade or so ago doing that.

> 
> You can do this with rpm as well, but it requires greater care.
> 
>> Here is
>> an example of what I have been trying to do, ex:
>> 
>>     list.txt,
>> 
>> 
>> gcc-devel // example,
>> 
>> python-devel //example
>> 
>> rpm -e // would this list content be redirectable to rpm -e ?
>> 
>> cat list.txt
>> 
>> lists rpms,
>> 
>> rpm -e < cat list, or
>> 
>> cat list | rpm -e
>> 
>> do not work.
> 
> Indeed, rpm doesn't take the list of packages on stdin.  You
> can use a number of techniques here (we all develop our
> favorite habits, but knowing "there is more than one way to
> do it"™ is always handy.
> 
> Here's how I setup a test:
> 
>    $ printf '%s\n' gcc-devel python-devel >/tmp/list
> 
>    $ cat /tmp/list
>    gcc-devel
>    python-devel
> 
> You could use xargs:
> 
>    $ xargs sudo dnf remove </tmp/list
> 
> This will display the 'dnf remove' output, showing you what
> it would do.  Then it will exit immediately because there is
> no way for it to read the 'Is this ok [y/N]:' prompt.  You
> can run it again with the '-y' option.
> 
> Another way to feed the list to dnf (or rpm) is to use
> command substitution:
> 
>    $ sudo dnf remove $(cat /tmp/list)
> 
> Bash¹ has a shortcut for that cat usage which is slightly
> faster:
> 
>    $ sudo dnf remove $(< /tmp/list)
> 
> ¹ Other shells likely have this is something similar, but
>  I'm not familiar with them offhand
> 
> A for loop works too, but that doesn't work very well when
> there are interdependent packages in the list (particularly
> with rpm, but even with dnf it can cause problems).  It's
> also a _lot_ slower to run the rpm or dnf command multiple
> times instead of once.
> 
> That's just two ways to go about it.  Hopefully they help.
> 
> -- 
> Todd
> _______________________________________________
> users mailing list -- users@lists.fedoraproject.org
> To unsubscribe send an email to users-le...@lists.fedoraproject.org
> Fedora Code of Conduct: 
> https://docs.fedoraproject.org/en-US/project/code-of-conduct/
> List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
> List Archives: 
> https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org
> Do not reply to spam on the list, report it: 
> https://pagure.io/fedora-infrastructure

Attachment: signature.asc
Description: Binary data

_______________________________________________
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org
Do not reply to spam on the list, report it: 
https://pagure.io/fedora-infrastructure

Reply via email to