Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: math, percentage
- X-seq: zsh-users 9806
- From: "Brian K. White" <brian@xxxxxxxxx>
- To: <zsh-users@xxxxxxxxxx>
- Subject: Re: math, percentage
- Date: Sat, 31 Dec 2005 15:44:23 -0500
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Organization: Aljex Software
- References: <024d01c60dd7$576ed990$931fa8c0@venti> <20051231072500.GJ39217@xxxxxxxxxxxxxxxx>
----- Original Message -----
From: "Dan Nelson" <dnelson@xxxxxxxxxxxxxxx>
To: "Brian K. White" <brian@xxxxxxxxx>
Cc: <zsh-users@xxxxxxxxxx>
Sent: Saturday, December 31, 2005 2:25 AM
Subject: Re: math, percentage
In the last episode (Dec 31), Brian K. White said:
is there a way to do this with built in math instead of running bc ?
tp=`echo "scale=0;(${t}*100)/$T" |bc`
T = some dynamic total number like `ls |wc -l`
t = counter that starts at 1 and incriments as a loop walks through T
tp = percent of total job completed so far
(( tp=t*100/T ))
Nice.
Never knew you could do the assignment inside the braces like that,
but even so I should have thought to at least try tp=$((t*100/T)) since I
use n=$((n+1)) a hundred times a day.
thanks
Brian K. White -- brian@xxxxxxxxx -- http://www.aljex.com/bkw/
+++++[>+++[>+++++>+++++++<<-]<-]>>+.>.+++++.+++++++.-.[>+<---]>++.
filePro BBx Linux SCO FreeBSD #callahans Satriani Filk!
Messages sorted by:
Reverse Date,
Date,
Thread,
Author