Artix Linux Forum

Artix Linux => Package management => Topic started by: Archie on 02 February 2025, 17:46:29

Title: More on filtering /var/log/pacman.log
Post by: Archie on 02 February 2025, 17:46:29
As a continuation of Octopi vs Synaptic (https://forum.artixlinux.org/index.php/topic,7729.0.html) 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 (https://hastebin.com/share/utawafemud.yaml)
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'
Title: Re: More on filtering /var/log/pacman.log
Post by: ####### on 02 February 2025, 19:56:13
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.
Title: Re: More on filtering /var/log/pacman.log
Post by: just_jed on 02 February 2025, 20:14:40
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.
Title: Re: More on filtering /var/log/pacman.log
Post by: Archie on 03 February 2025, 12:34:25
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'
}
Title: Re: More on filtering /var/log/pacman.log
Post by: just_jed on 04 February 2025, 02:08:10
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.