Zypper remove many packages

Is it possible to remove multiple packages listed in a text file? Similar to “cat orphan.txt | zypper rm” or “zypper rm <orphan.txt.” Neither worked.

Thanks.

Hello ionmich,

There are probably lots of ways to do this, here’s one:

zypper rm `cat orphan.txt`

Good luck!:wink:

Have not tried this, but I would expect
zypper rm cat orphan.text

or


for i in `cat orphans.txt`;do
zypper rm $i
done

Wrong. This tries to remove the packages named “cat” and “orphan.txt”.

Hello Knurpht,

It works for me, note that it’s a ` not a ’ or ".:wink:

Knurpht wrote:
> Edward_Iii;2384496 Wrote:
> Code:
> --------------------
> > > zypper rm cat orphan.txt
> --------------------
>
> Wrong. This tries to remove the packages named “cat” and “orphan.txt”.

What do you think backquotes do in the shell?

That’s one reason the POSIX syntax for command substitution uses $( ) instead

zypper rm $(cat orphan.txt)

Another is that $()s can be nested(for the reeeeally hairy shell scripts) without very ugly quote mixing.

The back quotes have been deprecated for at least 10 years.

Thanks all. I like the script. Simple.