0

I need to remove/ uninstall the list of packages those are found with the grep command.

pratap@PRATAP:~$ sudo apt list --installed | grep plymouth

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

libplymouth4/bionic-updates,now 0.9.3-1ubuntu7.18.04.1 amd64 [installed]
plymouth/bionic-updates,now 0.9.3-1ubuntu7.18.04.1 amd64 [installed]
plymouth-label/bionic-updates,now 0.9.3-1ubuntu7.18.04.1 amd64 [installed]
plymouth-theme-ubuntu-logo/bionic-updates,now 0.9.3-1ubuntu7.18.04.1 amd64 [installed]
plymouth-theme-ubuntu-text/bionic-updates,now 0.9.3-1ubuntu7.18.04.1 amd64 [installed]
pratap@PRATAP:~$ 

I want to uninstall the above packages immediately once the above command is executed.
How can I achieve this?

PRATAP
  • 22,460
  • That's an unusual way to do it. A safer way is usually to let apt remove the target package (which also removes the rdepends), then autoremove any orphaned dependencies. For example, lightdm depends upon plymouth. Must the selection be a grep? Apt will find a more complete list.... – user535733 Oct 23 '18 at 17:27

1 Answers1

1

Since you are grep'ing the output of all the installed packages that contain the word plymouth, you can instead pass a regular expression to apt's remove command.

You can run the following command

sudo apt remove 'plymouth.*' --dry-run

This will remove all packages that contain the word plymouth. However, since the command is using a wildcard like that, it might be dangerous and so it's better to review the changes first, hence the --dry-run parameter.

This will allow you to validate what would happen when you run that command, without actually removing anything. If you are satisfied, you can just rerun the same command without the --dry-run parameter.

The following packages will be REMOVED:
  libplymouth4 plymouth plymouth-label plymouth-theme-ubuntu-logo
  plymouth-theme-ubuntu-text
0 upgraded, 0 newly installed, 5 to remove and 0 not upgraded.
Remv plymouth-theme-ubuntu-text [0.9.3-1ubuntu10]
Remv plymouth-theme-ubuntu-logo [0.9.3-1ubuntu10]
Remv plymouth-label [0.9.3-1ubuntu10]
Remv libplymouth4 [0.9.3-1ubuntu10] [plymouth:amd64 ]
Remv plymouth [0.9.3-1ubuntu10]
Dan
  • 13,119