summaryrefslogtreecommitdiff
path: root/bin/common/whenpkgs
diff options
context:
space:
mode:
Diffstat (limited to 'bin/common/whenpkgs')
-rwxr-xr-xbin/common/whenpkgs30
1 files changed, 30 insertions, 0 deletions
diff --git a/bin/common/whenpkgs b/bin/common/whenpkgs
new file mode 100755
index 0000000..96c45d0
--- /dev/null
+++ b/bin/common/whenpkgs
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+m="$(date +%m)"
+d="$(date +%d)"
+y="$(date +%y)"
+
+# Trying to make a regex that will match expac's date format
+
+# 1. create ranges based on command line arguments
+# 2. change this to \(n-2\|n-1\|n\)
+# I. generate sequence
+# II. remove trailing space
+# III.translate space to '\|'
+# IV. wrap everything in '\( ... \)'
+# V. shift command line arguments
+# repeat 2. for month and year
+# 3. seq outputs a newline, translate this to slash
+# 4. remove trailing slash
+regex="$(for var in m d y
+do
+ seq -w -s ' ' $((${!var} - ${1:-0})) ${!var} |
+ sed 's/ /\\|/g;s/.*/\\(&\\)/'
+ shift 2>/dev/null
+done |
+ tr '\n' '/' |
+ sed 's/.$//')"
+
+expac -t %D '%l %n' |
+ grep "$regex" |
+ sort -k 2 -t '/' -n