💾 Archived View for 1436.ninja › Phlog › gmi › 20230911.gmi captured on 2024-06-19 at 22:49:59. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-09-28)

-=-=-=-=-=-=-

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.