You are not logged in.

#1 2019-01-13 07:31:31

es20490446e
Banned
Registered: 2017-12-29
Posts: 46
Website

Removing only not installed packages

Imagine that I have a list of packages, some installed some not, stored in a terminal variable called ${packages}.

What commands would removed only the installed ones?

Offline

#2 2019-01-13 07:37:06

Stratoblaster
Member
From: Florida
Registered: 2018-12-04
Posts: 59

Re: Removing only not installed packages

Have a look at this from the wiki

https://wiki.archlinux.org/index.php/Pa … base_group


Other than that, I suppose reading more from this link, you could get a listing of currently install packages, then work with that file anyway you see fit.

Last edited by Stratoblaster (2019-01-13 07:38:47)


Supercalifragilisticexpialidocious

Offline

#3 2019-01-13 11:14:27

pipep
Member
Registered: 2016-12-04
Posts: 10

Re: Removing only not installed packages

Offline

#4 2019-01-13 11:24:23

HiImTye
Member
From: Halifax, NS, Canada
Registered: 2012-05-09
Posts: 1,072

Re: Removing only not installed packages

there's already a tool for this. no need to reinvent the wheel.

# paccache -ruk0

that is, unless you need it for some reason other than clearing your cache, which doesn't really make sense unless you're just trying to get us to do your homework.

Offline

#5 2019-01-13 14:48:27

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,520
Website

Re: Removing only not installed packages

HiImTye, the OP doesn't mention anything about clearing the cache.

es20490446e, the way I read your question is that you have a list of packages (probably requirements) and you think you need to remove the ones that are already installed.  If that was the right way to acheive your goal you could use `comm` on that list and the output of `pacman -Qq`.  But I'm pretty sure this is an X-Y question.  Do you really want to ensure that all the packages on that list are installed while not reinstalling those that already are?  If so:

pacman -Syu --needed $YOUR_LIST

Or by "remove" do you mean you want to uninstall everything on that list?  In that case, use a comm command to generate a list of removal targets and pass that to pacman.  Unfortunately there is not --needed like flag for removal of packages (e.g., remove it it is there or ignore).  And a `pacman -R` command will not do anything if any of the provided targets are not found on the system.

Last edited by Trilby (2019-01-13 14:51:35)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#6 2019-01-13 18:49:31

es20490446e
Banned
Registered: 2017-12-29
Posts: 46
Website

Re: Removing only not installed packages

So it seems that sorting first, removing after, is the simplest solution.

Offline

Board footer

Powered by FluxBB