Skip to main content
Topic: More on filtering /var/log/pacman.log (Read 212 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

More on filtering /var/log/pacman.log

As a continuation of Octopi vs Synaptic post...

Finding out the chronological install or remove date and time of packages is a simple:

Code: [Select]
~ > grep "installed" /var/log/pacman.log
or
Code: [Select]
~ > grep "removed" /var/log/pacman.log

Grouping a particular date, never mind the time duration, is what I wanted to point out on the above mentioned thread/discussion.

Example: pacman.log
or try in on your own logfile.

And say, I just wanted the list of packages installed or upgraded on Jan. 7th.

Code: [Select]
~ > sed -E '/2025-01-07/!d' /var/log/pacman.log | grep 'installed'
or
Code: [Select]
~ > sed -E '/2025-01-07/!d' /var/log/pacman.log | grep 'upgraded'
S6/Plasma

Re: More on filtering /var/log/pacman.log

Reply #1
To add to my earlier suggestion of nano, if you press Alt / (forward slash) having opened the log in nano you jump to the end of the file. Ctrl W does a case insensitive search so if you input the date or package name you jump right to it. Alt W searches for the next occurence. Once you know some keyboard shortcuts it's very easy to jump to the right place. Other text editors have similar features.

You could work out some pattern searches and make them into a script or bash alias too, of course.

Re: More on filtering /var/log/pacman.log

Reply #2
You're giving me flashbacks! :)

It was probably 1995 when I bought O'Reilly's sed, grep, and awk book. Was writing Oracle stuff on a Data General.  :o

I tend to forget that sed even exists.

Re: More on filtering /var/log/pacman.log

Reply #3
I get the same vibes even from my local friends whenever I mention ... something retro. 😺

I just added to my .bash_aliases the following aliases:
Code: [Select]
---SNIP---
alias wid='qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.wallpaper 0 | grep "Image: file:" | cut -d "/" -f 3- | rainbow'
alias x='exit'
alias X='cat /dev/null > ~/.bash_history && history -c && exit'
alias xitra='supybot /home/archie/Temporary/xitra/xitra.conf'

pkgin() {
    if [ -z "$1" ]; then
        echo "Usage: pkgin <date>"
        echo "Example: pkgin 2025-01-07"
        return 1
    fi
    sed -E "/$1/!d" /var/log/pacman.log | grep 'installed'
}

pkgrm() {
    if [ -z "$1" ]; then
        echo "Usage: pkgrm <date>"
        echo "Example: pkgrm 2025-01-07"
        return 1
    fi
    sed -E "/$1/!d" /var/log/pacman.log | grep 'removed'
}

pkgup() {
    if [ -z "$1" ]; then
        echo "Usage: pkgup <date>"
        echo "Example: pkgup 2025-01-07"
        return 1
    fi
    sed -E "/$1/!d" /var/log/pacman.log | grep 'upgraded'
}
S6/Plasma

Re: More on filtering /var/log/pacman.log

Reply #4
I just added to my .bash_aliases the following aliases:
I should do more of that. Too many useful things, I just don't remember them. If nothing else, an alias file is a nifty ersatz documentation spot.