On 08/02/2021 09:40, Nev Young wrote:
On 07/02/2021 11:53, Phil Thane wrote:
Hello,
Anyone know if this exists or would anyone like to create it? (Not seq command, won't do what I want, I don't think). Read on...
I'm the membership sec of GOBA (Great Ouse Boating Assoc). We've just launched a new website using WP and sundry plugins. Central to things is Paid Memberships Pro which allows new members to join or existing ones to renew online. PMP allows users to specify their own username and password. BUT, under the previous regime and going back to the dark ages (pre internet) GOBA assigned each member a membership number, and just to make life more difficult didn't just use a straightforward sequence. Each 'number' is actually alphanumeric based on initial letter of the member's surname, then the next number available in that sequence. Thus I'm T596 and there is one person after me T597 but in the S list there are over 1200 (too many Smiths).
That's do-able via the WP dashboard but a bit of a pain. Finding the last number issued on a particular sequence involves inspired guesswork and wildcard searching. I believe a previous membership sec had an app on an ancient version of Windows that kept a log of the last issued numbers so he just input an initial letter and got back the number. Obviously I'd have to find 26 last issued numbers manually to get started but subsequently it'd be a lot easier.
You can make things easier for yourself by only having one number list. So if you have 3124 members the next new member would be <1st initial>3125. After all, you probably already have voids in the existing lists from members leaving. It would also make things easier when Miss Jones changes to Mrs Smith as the number part wont have to change.
Try this if you want. Not clever but it works. #! /bin/bash
cd ~ # <replace with your working directory> index=$(cat lastnumber.txt)
index=$(($index + 1)) echo "next number is " . $index echo $index > lastnumber.txt
Nev
I like Nev's solution because a) it's very simple b) it cunningly works around the problem and last but not least c) he didn't tell you that you don't want to do what you want to do. :-)
Steve