NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

OT bc in the Real World



It's off-topic but I recently used bc in a script I put together to do
basic backups at various levels.

The code to calculate which dump level to use (ab)uses date and bc with
the julian number:

level () {
  # find the backup level using towers of hanoi - h(index, max, start)
  _h="define h(d,m,l){if((d-1)%%(2^m)){return h(d,m-1,l+1)}else{return
  l}}"
  date "+$_h;h(%j,3,0)" | bc
}

Unfortunately none of my work colleagues appreciated this ... :/

Regards,
Malcolm

-- 
Malcolm Herbert                                This brain intentionally
mjch%mjch.net@localhost                                                left 
blank


Home | Main Index | Thread Index | Old Index