Bash 67 chars
read t u d w
echo -e '\t'|expand -t $d|sed 's/^/8/;s/ /=/g;s/$/B/;'
invocation to the letter of the assignment:
uptime | ./cg1570uptime-bar.sh
Much shorter
just 54 chars:
with this variation:
echo -e '\t'|expand -t $3|sed 's/^/8/;s/ /=/g;s/$/B/;'
invocation, not 100% in accordance with the rules:
./cg1570uptime-bar.sh $(uptime)
output in both times:
uptime && uptime | ./cg1570uptime-bar.sh
06:29:53 up 16 days, 21:03, 10 users, load average: 1.29, 1.34, 1.23
8================B
Non-everyday tricks:
read t u d w
reads 06:29:53=t, up=u, 16=d rest...=w
without w, everything to the end would be put into $d.
expand is normally used to translate a tab into an amount of blanks and takes a parameter if you don't like 8.
Grabbing the 3rd parameter with $3 in echo -e '\t'|expand -t $3|sed 's/ /=/g' is even shorter, but needs an invocation, not fitting to the words of the rules.
What does that 8 and D (
8====D) mean? Do we have to reproduce it? Does it has a special meaning, everybody knows (except me)? – user unknown – 2012-04-13T03:59:43.4331@userunknown It had relevance in the first version of this question. Have a look at the edits... – Gareth – 2012-04-13T11:24:34.727
Well, I see. However, I would recommend an uppper B instead of D, wouldn't I? – user unknown – 2012-04-13T15:30:12.887
@dmckee: Thanks for the edit. However, there's a minor spelling error: 'a anotomically' should read 'an anatomically'. – Joey Adams – 2011-03-13T00:11:13.847
@Joey: And I misspelled "anatomically", too. Thanks. – dmckee --- ex-moderator kitten – 2011-03-13T00:13:10.773
5Hmm, just a nitpick, a "progress bar" for something that doesn't have a known end (so, you can't measure its progress) sounds weird. Maybe just "bar" would be enough? – houbysoft – 2011-03-13T01:19:48.397
@houbysoft: The known end is 497 days, of course. – Chris Jester-Young – 2011-03-13T17:17:36.670
2My uptime is 27 minutes :( – steenslag – 2011-03-13T22:24:44.603