Skip to content

A silly loop to dump the names of all your installed packages into a file, listed alphabetically

Just in case you'd like to see what's on board. And no, pacman won't harass you for a password with -Q.

for i in {a..z} ; do echo -e ${i}":"$'\t'$(pacman -Qq | grep ^${i}) >> pkgs.txt ; done

Feel free to adopt, adapt, improve, enhance, simplify, modify, stultify, transmogrify, steal, pilfer, fold, bend, or mutilate.

9 points7 comments
Open on Reddit
About this post
Posted
Archived
Score
9 · 100% up
Kind
Text
ID
2d2qpr

Author

1
posts
9
comments
0
media
View profile

7 comments

26 invocations of pacman and 26 invocations of grep and 26 open/seek/write/close operations on pkgs.txt?

pacman -Qq | awk '
    /^[a-z]/ {
        init = substr($1, 0, 1);
        pkgs[init] = pkgs[init] "\n" $0;
    }
    END {
        for (letter in pkgs) {
            printf "%s:%s\n", letter, pkgs[letter];
        }
    }' > pkgs.txt
11 points

The output of pacman -Q is already sorted alphabetically…?

8 points

"Grouped" alphabetically probably would have been a better title.

3 points

I have something similar that parses /var/log/pacman.log and outputs all the packages I explicitly installed and categorizes them as either from the main repos or from AUR. It's nice having this easy to read record when I eventually decide to try out a new distro, decide it's not as good as arch, and come back.

3 points

Or just use sed:

pacman -Qq | \
    sed 'x;G;s/^\(.\):\n\1.*/\1:/;t match;s/.*\n\(.\).*/\1:/;p;x;b;:match;x' >pkgs.txt
2 points

Er not sure why this is so long to type? Why not just use:

pacman -Q > txt ; vim txt

1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.