DEV Community

Aitor
Aitor

Posted on

How to clean orphan packages in one line

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

Top comments (1)

Collapse
 
mdev88 profile image
Martín Vukovic

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