Lazy list management

I use a couple awk scripts to manage a list of students who come to church with me every week. When a student tells me he will be coming on Sunday, I put an asterisk (*) in front of his name in a static text file with everyone’s names. If they tell me they won’t be coming, I put a minus sign (-) in front of their name so I remember that they said so. If for some reason I’m not sure, I put a question mark (?).

My main script spits out a list of all the students who are coming (i.e., have an asterisk). There’s no genius to it, I’m just logging it here for reference.

I also have another script that wipes all the attendance marks out of the main list file.

Files

All files are available here:

Source is posted below without comment since it’s basically self-explanatory.

StudentList.bash

awk 'substr($1,0,1) == "*" { print substr($0,2,length($0)) } ' students.txt > studentsComing.txt
cat studentsComing.txt

WipeStudentList.bash

awk -f Wipe.awk <students.txt >temp
cat temp >students.txt
rm temp
./studentlist.bash

Wipe.awk

{if ( substr($1,0,1) == "*" || substr($1,0,1) == "-" || substr($1,0,1) == "?" )
  { print substr($0,2,length($0))  }
 else
  { print $0 }
}

2 Responses to “Lazy list management”


  • Something tells me that the number of people using AWK to manage their extension is rather small… :)

  • Probably so, but lazy is as lazy does! I needed a good excuse to write awk one day, and this is the result. I think my “production version” does a few more fancy things now, but haven’t used it for so long that I forget completely.

Comments are currently closed.