LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] Life on a Linux box

[ILUG] Life on a Linux box

Fiona Whelan fiona.whelan at ireland.com
Wed Mar 14 01:06:22 GMT 2001


Hey all,
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,



  _
 |_
 |  I O N A
_____________________________________

Get your free E-mail at http://www.ireland.com




More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


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!
RSS Version
Powered by Dell