Created
August 8, 2024 03:04
-
-
Save realyukii/b26b85cc8e76d3132ae6080316428f1f to your computer and use it in GitHub Desktop.
[ARCH LINUX PACMAN] print the sorted date and formatted output of pacman -Qei
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
pacman -Qei | grep --color=never -E '^(Name|Install Date)' | awk -F': ' '/^Name/ {name=$2} /^Install Date/ {print $2, name}' | awk ' | |
BEGIN { | |
# Define month names for conversion | |
split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec", months, " ") | |
} | |
{ | |
# Extract the date and time parts | |
if ($1 ~ /^Mon|Tue|Wed|Thu|Fri|Sat|Sun/) { | |
day = $2 | |
month = $3 | |
year = $4 | |
time = $5 | |
ampm = $6 | |
timezone = $7 | |
pkgname = $8 | |
# Convert the month to a number | |
for (i = 1; i <= 12; i++) { | |
if (month == months[i]) { | |
month_num = (i < 10 ? "0" i : i) | |
break | |
} | |
} | |
# Convert the date to YYYY-MM-DD HH:MM:SS | |
print year "-" month_num "-" day " " time " " ampm, timezone, pkgname | |
} | |
}' | sort |
to find the duplicate: awk -F"'" '{print $2}' /var/log/pacman.log | grep --color=never -E 'pacman -S [^ ]+' | sort | uniq -d
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can also do the alternative:
grep -E 'pacman -S [^ ]+|asexplicit' /var/log/pacman.log
this alternative address the initial date problem