[Lvlug] I was bored..

Linc Fessenden linc@thelinuxlink.net
Thu, 13 Jun 2002 21:08:48 -0400 (EDT)


On Thu, 13 Jun 2002, jab wrote:

> linc,
> 
> this works for me ... although it does tend to rack up the
> process id's ... and it's not using bc to format per desire ...
> 
> played around a little trying to eliminate the extra vars
> (hrs, hrs2 ....), but i've got a filet in need of consumption ...
> 
> jim
> 
> 
> #!/usr/bin/bash
> clear
> while : ;
> do
>   # set to 0 for multiline output
>   oline=1;
> 
>   hr=`date +%H`;
>   hrs=`echo "obase=2; $hr"|bc`;
>   hrs2=`echo $hrs|awk '{printf("%06.0d\n", $1)}'`;
> 
>   mi=`date +%M`;
>   mis=`echo "obase=2; $mi"|bc`;
>   mis2=`echo $mis|awk '{printf("%06.0d\n", $1)}'`;
> 
>   se=`date +%S`;
>   ses=`echo "obase=2; $se"|bc`;
>   ses2=`echo $ses|awk '{printf("%06.0d\n", $1)}'`;
> 
>   if [ "${oline}" -eq 1 ]
>   then
>     tput cup 0 0; echo "$hrs2 $mis2 $ses2";
>   else
>     tput cup 0 0; echo "$hrs2";
>     tput cup 1 0; echo "$mis2";
>     tput cup 2 0; echo "$ses2";
>   fi
> done

AHHHHH, another bash coder :-)  Goodie - someone to bounce ideas off of!
Try this on on for size and see whatcha think..

#!/bin/bash
clear
blank="000000"
while : ;
	do 
		hr=`date +%H`; bhr=`echo "obase=2; $hr" | bc`;
		mi=`date +%M`; bmi=`echo "obase=2; $mi" | bc`;
		se=`date +%S`; bse=`echo "obase=2; $se" | bc`;
		tput cup 0 0; echo ${blank:`expr length $bhr`}$bhr;
		tput cup 1 0; echo ${blank:`expr length $bmi`}$bmi;
		tput cup 2 0; echo ${blank:`expr length $bse`}$bse;
	done


-- 
-Linc Fessenden

In the Beginning there was nothing, which exploded - Yeah right...