begin Fiona Whelan quotation:
> I have written a script in bash that calculates the % of a person's
> life that they spend connected to a linux box. It is rather long, so
> I was wondering what is the best way to go about it.. probably
> something like perl can do it much quicker. What the bash script
> does is this: use the 'last' command to get login info for the user
> (supplied as argument to the script), cut out the time bit using
> 'cut' (ie getting the brackets bit), cut the time bit into hours and
> minutes, add up all the hours, add up all the minutes, and calculate
> total time.. all this work using 'expr' in for..do..done loops,
> display this information as "accumulated hours" and finally express
> this as a percentage of the time that has lapsed since their first
> login. Sound like a lot of work? I did all this for fun! (yes, sad).
> I know perl has one-liners for a lot of things... but not for this
> sort of thing, right? I am learning perl now and my first task is to
> re-write this bash script in as few lines of perl as I can. Can
> anyone give me some pointers as to method? Thanks,
Total: 66472.04 over 241 days.
Since I open multiple shells, it even tells me that it isn't
that many *consecutive* hours.
You are not entitled to your opinions.
01234567 <- The amazing indent-o-meter!
^ Matt McIrvin: the Nikola Tesla of tab damage.
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!