DEV Community

loading...

How to clean orphan packages in one line

torswq profile image Aitor Santoro ・1 min read

I am not a GNU/Linux master, nor a terminal expert, i was going to make a bash script to clean orphan packages, then i read this...

Using arrays or loops in shells is often signs of bad coding practice.


... So i decided to research about awk, and i did this one-line command to clean your orphan pacman packages sudo pacman -R $(pacman -Qdt | awk '{print $1}')

  • pacman -Qdt: Used to display the orphan packages.
  • awk '{print $1}': Prints the first field of the output.

e.g

Discussion (1)

Collapse
mdev88 profile image
Martín Vukovic

You can use --noconfirm as an equivalent of -y in apt, to disable user confirmation ;)

Forem Open with the Forem app