Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: math, percentage
- X-seq: zsh-users 9804
- From: "Eric Mangold" <teratorn@xxxxxxxxxxxxx>
- To: "Brian K. White" <brian@xxxxxxxxx>, zsh-users@xxxxxxxxxx
- Subject: Re: math, percentage
- Date: Sat, 31 Dec 2005 18:22:14 +1100
- In-reply-to: <024d01c60dd7$576ed990$931fa8c0@venti>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <024d01c60dd7$576ed990$931fa8c0@venti>
Here are some ideas:
total=15
typeset -F 2 percentage # only show two decimal places when formatting
for i in {1..$total}; {
print $i of $total
percentage=$(( $i.0 / $total * 100 ))
print percentage $percentage
}
On Sat, 31 Dec 2005 17:56:35 +1100, Brian K. White <brian@xxxxxxxxx> wrote:
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
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