I needed to print all my stash flavours and their associated bottle numbers (which I have entered as the first word in the Notes field). The attached script does this and outputs a CSV of flavour,bottle nomber pairs.
Oh! Can’t seem to upload non-images. Here it is:
#!/usr/bin/awk -f
# Date: 18Feb17
# Name: flavourstashconverter.awk
# Description: A gawk program to format http://e-liquid-recipes.com/printStash (saved as html text) from e.g. :
# *Acetyl Pyrazine 5% (TPA)*
# FirstWordOfNotes more words ...
# 30.00 ml
# ...
# to:
# Acetyl Pyrazine 5% (TPA),FirstWordOfNotes
# (any other stuff is trashed.)
# If, say, you have entered the first word of Notes as your private flavour number this will print all your
# flavours with their stash number as a CSV so you can easily print a lookup table and pick the right bottle
# from your carefully labelled stash you spent so much time organising. Or you can import it into a spreadsheet ...
# Usage* : ./flavourstashconverter.awk filename
# e.g. : ./flavourstashconverter.awk 'My flavor stash.html'
# * remember to chmod +x flavourstashconverter.awk first, but you knew that.
# Author: MixedUp2
# NOTES
# 1. Output is in the order output by ELR i.e. alphanumeric by flavour name.
# 2. To sort the output by the first word of the notes field (stash number):
# ./flavourstashconverter.awk 'My flavor stash.html' | sort -t , --key=2.1
# This is useful for checking holes in your numbering system.
# 3. Tested (quickly), on my stash only, under Linux Mint 18, GNU Awk 4.1.3. (Windows, Android & Mac users need not apply.) :)
# Bugs.
# I think not. ;)
BEGIN { RS = "1 2 3 4 5"; FS="\n"; }
{
if ($1 != "e-Liquid Recipes"){
#print flavour ($2) without leading/trailing asterisks, a comma, then first word of Notes ($3)
printf("%s,%s\n", substr($2,2,length($2)-2),gensub(/^\s*(\S+).*/,"\\1",1,$3) )
}
}
Eugh! Had to fight to get that displaying correctly. If it works for you, my name is MixedUp2 if it doesn’t, my name is daath.