More Debt Watching from the Command Line
Aug 13, 2009, 23:32 (0 Talkback[s])
(Other stories by Mitch Frazier)
"The first function, get_debt(), fetches the debt page from
brillig.com and then extracts and cleans up the debt number. The
debt number is extracted from the alt attribute of the image at the
top of the page. The string there contains spaces and commas and a
dollar sign, those are removed to give us a usable number.
"The second function fmt_time() formats a time component for our
output. For example, fmt_time 2 second prints "2 seconds", fmt_time
0 second prints "" (an empty string).
"The third function, elapsed_time() takes two time values in
seconds and calculates the difference between the two. It then
formats the elapsed time in a readable fashion. For example
elapsed_time 0 3659 prints "1 hour 59 seconds".
Complete Story
Related Stories:
- Bash Shell Course: Text Editors(Aug 12, 2009)
- Adding Document templates to Nautilus right click menu(Aug 07, 2009)
- A First Look at Python Classes(Jul 29, 2009)
-
System monitoring with Conky(Jul 28, 2009)
- Tech Tip: Some Useful Vim Options(Jul 28, 2009)
- Take Beautiful Web Screenshots from the Command Line with khtml2png(Jul 26, 2009)
- Linux tip: Creating a pixel ruler from the command line(Jul 24, 2009)
- Course: Bash Shell Basics(Jul 20, 2009)
- Scripting the Vim editor, Part 2: User-defined functions(Jul 10, 2009)