DEV Community

Aitor
Aitor

Posted on

2 1

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 ;)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay