#!/bin/bash ## subsetMBRStoSMALL -- used from generateElistFromHISTORY+MBRS -- Eugene Reimer 2007-Mar; ## ## note: Peggy sends 2 kinds, which i refer to as: ## BIG -- all membership records since 2000-Jan -- i give these filenames containing "BIG" ## SMALL -- only the current In-Good-Standing members -- i give these filenames without BIG -- also without SMALL:-) ## -- whereas her "small" contains only In-Good-Standing members, ## my SMALL constructed from a BIG, includes those delinquent by less than a year -- BUT ONLY early in the year (Jan..May); ## ## USAGE: ## subsetMBRStoSMALL BIG-htmfile DEST-SMALL-htmfile <-- only because generateElist script had both names handy:-) BIG=$1; DST=$2; [ $# -ne 2 ] && { echo "usage subsetMBRStoSMALL BIG-htmfile DEST-SMALL-htmfile"; exit; } ##set -v ##YY=$(date +%y); MM=$(date +%m) ##get current year YY, month MM, and PP=(YY-1) (pre-07oct) MDATE=${BIG/MBRS/}; MDATE=${MDATE/-BIG/}; MDATE=${MDATE%%.*} ##get MDATE from the input MBRS-db-name (07oct) YY=${MDATE:2:2};yy=10#$YY; MM=${MDATE:4:2};mm=10#$MM ##get year YY and month MM from the input MBRS-db-name (07oct) ((P=yy-1)); PP=$(printf "%02d" $P);pp=10#$PP ##get previous year PP = (YY-1) echo -n "subsetMBRStoSMALL: YY=$YY MM=$MM PP=$PP -- continue??"; read ##DEBUG 07oct ## COLUMNS: eg: to select those who paid dues for 2005 or 2006, test for columns 32 or 34 non-null; ## Dues2004 is col 29 ## Dues2005 is col 32 -- since 2005, she's been adding exactly 2-columns per year (previously she added 3 per year) ## Dues2006 is col 34 ## Dues2007 is col 36 (I hope it will be) ## DERIVE column-nbrs from the year: Dues-YY is col 32+2*(YY-05) <--EVEN BETTER WOULD BE to find the "Dues YYYY" heading in first row of table?? ## ## ALGORITHM: When MM < 06, then select based on Dues-YY-1 OR Dues-YY; when MM>=06, use only Dues-YY; ## ((DuesYY= 32 + 2 * (yy-5) )) ##Dues-column-nbr for current-year YY ((DuesPP= 32 + 2 * (pp-5) )) ##Dues-column-nbr for previous-year PP grep '
||; s| | |~|g' |tr '~' '\n' >tmpColHeadings ##write ColHeadings temp-file, for checking... hdgYY=$(head -n$DuesYY tmpColHeadings |tail -n1) ##Dues-column-contents for year YY from the ColHeadings hdgPP=$(head -n$DuesPP tmpColHeadings |tail -n1) ##Dues-column-contents for year PP from the ColHeadings if [[ $hdgYY != 20${YY}Dues* ]];then echo "subsetMBRStoSMALL: column$DuesYY: EXPECTING:20${YY}DuesDate, FOUND:$hdgYY"; fi ##expect hdgYY to be 20${YY}DuesDate if [[ $hdgPP != 20${PP}Dues* ]];then echo "subsetMBRStoSMALL: column$DuesPP: EXPECTING:20${PP}DuesDate, FOUND:$hdgPP"; fi ##expect hdgPP to be 20${PP}DuesDate if ((mm<6)); then ##--Month is Jan..May, select BadStanding as well as GoodStanding members cat $BIG | sed 's| |~|g; s| | | |
| |