I'd like to grep through pacman -Q
As title says, I would like to use grep with the output of pacman -Q to get the following packages (and their versions):
-
kernel
-
grub
-
systemd
-
gnome
-
nvidia
Can anyone point me to the right direction please?
EDIT: Thanks for the help guys! Here is my script (it's still a work-in-progress) https://github.com/bill-mavromatis/arch-discover/blob/master/discover.sh Eventually I want to grab the output of the script and either put it on a conky config, or maybe generate an SVG for a cool-looking wallpaper. Thanks again.
Edited 6 Apr 2017. We only hold this version.
About this post
- Posted
- Archived
- Edited
- Score
- 1 · 100% up
- Kind
- Text
- ID
- 63ry81
22 comments
Yeah, I'm not sure why OP wants to involve
grephere:already prints the exact info (name + version) that OP is requesting.
Or if you need the output in a single line, you can pipe it through
xargs.Yep, I'm stupid I should have said I was looking for a way to pipe out the version separately. In hindsight, maybe not even that would be necessary but oh well, at least it was a learning experience... I'm actually very new to arch so it didn't even occur to me that you can add many packages after pacman -Q =/
Wow awesome!!! That's exactly what I was looking for! Thanks.
Edit: on second look, -Qi is closer to what I wanted because I wanna check the local installed packages. Still, works great. Now I'm just adding commands on top of the bash script such as:
to query which init, DE, wm, graphics etc are running first. Then after I get the right packages, I will place the variable names inside the brackets of your command. Thanks a lot!
TIL egrep is awesome.
You can also use regular (pun intended)
grepwithgrep 'Name\|Version', but yes, it's convenient to not have to escape meta-characters.From: Manual page egrep(1)
You could also just do
(also replaced the egrep with grep -E)
What is your end goal? Do you want to know the versions of the packages?
Yes. Ultimately I would like to have a script that queries all your important system software so would output:
And possibly expand that a bit more later (maybe add a nice GUI, and also have a changelog highlights next to each package). But I know that's too much to ask (unless you can point me to something that is already out there), so I just want a starting point, so probably grepping from pacman -Q is a good start. It's something I want for me, but maybe it's useful for others too.
You might want to look into just calling libalpm, maybe through pyalpm.