More Debt Watching from the Command Line

Written By
MF
Mitch Frazier
Aug 14, 2009

“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

MF

Mitch Frazier

Linux Today Logo

LinuxToday is a trusted, contributor-driven news resource supporting all types of Linux users. Our thriving international community engages with us through social media and frequent content contributions aimed at solving problems ranging from personal computing to enterprise-level IT operations. LinuxToday serves as a home for a community that struggles to find comparable information elsewhere on the web.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.