29

I know following code will remove all package from specific repo.

yum remove $(yum list installed | grep rpmforge | awk '{ print $1 }')

And following code will remove a package without dependencies.

rpm -e --nodeps "php-sqlite2-5.1.6-200705230937"

But i don't know how to use together.

Hamidreza
  • 1,825
  • 4
  • 29
  • 40

5 Answers5

41

Print list of all repositories to get repo id (first column):

$ dnf repolist

Now remove all packages of selected repo:

# dnf repository-packages <repo-id> remove

See repository-packages section of dnf manual page for details regarding manipulation with all packages in specific repository.

czerny
  • 15,090
  • 14
  • 68
  • 96
18

Try the following command:

rpm -e --nodeps `yum list installed | grep rpmforge | awk '{ print $1 }'`
robinwen
  • 852
  • 10
  • 10
  • You can also just use `awk` for the search. E.g. `yum list installed | awk '($3 ~ "rpmforge") {print $1}' | xargs rpm -e --nodeps` – tacotuesday Oct 19 '17 at 17:43
3

I like using
yum -y autoremove yum list installed | grep rpmforge | awk '{ print $1 }'

  • `yum -y autoremove $(yum list installed | grep ius | awk '{ print $1 }')` – Kurt Sep 13 '18 at 19:29
  • 2
    For the fyi, when you output yum through a pipe, it doesn't always print entries on a single line. (How flippin' frustrating is that??) If there's a package with a long name that came from the repo you're interested in, it might display the package name on one line, then a newline, then the version and repo columns. That would mean that your grep for the repo name might not catch the associated package name and your command wouldn't work. There's no way to make it work. To see what I'm talking about, do a 'yum list installed | less'. – Todd Walton Sep 17 '19 at 14:29
2

Check to Make Sure That You're Erasing Only What You Want To

dnf list installed | grep package_name.i686 | awk '{ print $1 }' | less

Actually Do The Removing

sudo rpm -e --nodeps `dnf list installed | grep package_name.i686 | awk '{ print $1 }'`
AldaronLau
  • 1,044
  • 11
  • 15
0

This one works with multiple versions of the same package

sudo rpm -e --nodeps `dnf repoquery --installed --queryformat '%{name}-%{epoch}:%{version}-%{release}.%{arch} %{from_repo}' | grep -i "reponame" | awk '{print $1}'`
konradmb
  • 111
  • 2