Automating a roster with bash

59 views Asked by At

I have to create a cleaning roster for an appartment building and would like to automate it with GNU bash if possible.

Requirements:

  • The tenants have to clean the corridor on their floor every week.
  • The cycle starts on Feb. 11, 2019 and lasts for 30 weeks (10x3).
  • There are 4 floors to my building.
  • There are 10 tenants capable of doing the task per floor.
  • The names of the tenants are in the 3rd column of the file tenants.csv, (sep = |).
  • The 1st column contains the appartment number which if it starts with a 2, such as in 214 means they are located on Floor number 2.

I would like to generate the dates automatically (maybe from the Date command with the week number %V which is starting on mondays) and merge in the names of the tenants from the csv file. Use of the date command and %V is way more complicated than I am used to. I don't know how to tackle this.

Desired Output (sample taken from the 2018 roster):

Week of                 Floor 1     Floor 2     Floor 3     Floor 4
Sep 18, Nov 27, Feb 5    Ms.X        Mr.Y        Ms.XX       Mr.YY
Sep 25, Dec 4, Feb 19    Ms.AA       Ms.BB       Mr.CC       Mrs.DD
...

So far, I have only this as the displaying (which i can handle i think) depends how i get the date command to give me the proper dates:

roster_start=$(date -d "20190211")   # 11 fev 2019 start of cleaning roster

yr=2019; wk=6

date -d "Feb 6 $yr" +%V

date -d "20190211"

printf "\nWeek of\tFloor 1\t\tFloor 2\t\tFloor 3\t\tFloor 4\n"; \
for wk in 6 16 26 "$yr"; do



printf "%s\t" "$d"



date -d "$wk" +"%b %e"

done

Thank you for any help you can provide.

0

There are 0 answers