mkrec script

This morning I moved Port70News to a recutils DB

This was super easy because of my mkrec script that takes a gophermap and spits out a rec file:

#!/bin/bash

if [[ "$1" == "--help" ]] || [[ -z "$1" ]]; then
    printf "mkrec: gophermap to recutils db\n  \
    Usage: $(basename "$0") file category\n"
    exit
fi
cat "$1" | \
awk -v x="$2" 'BEGIN { FS = "\t" } \
{ print "Category: " x "\nType: " substr($1,1,1)\
"\nLinkTxt: " substr($1,2) "\nPath: " $2 \
"\nDomain: " $3 "\nPort: " $4 "\n" }'

For the p70n.rec database I didn't need a category field, so I ran:

mkrec /var/gopher/Port70News/submissions.txt | mkrec | \
sed '/^Category/d' > p70n.rec 

Then a simple recsel using the -n option in conjunction with wc -l and bc to get the last row number and the last row minus 30. This results in a recordset containing the last 30 rows of the database which I pipe into recfmt to turn into gophermap syntax, then pipe to tac to get last submissions first.

Proxy Information
Original URL
gemini://1436.ninja/Phlog/gmi/20230911.gmi
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
797.988966 milliseconds
Gemini-to-HTML Time
0.286956 milliseconds

This content has been proxied by September (ba2dc).