zsh-users
 help / color / mirror / code / Atom feed
From: "Eric Mangold" <teratorn@world-net.net>
To: "Brian K. White" <brian@aljex.com>, zsh-users@sunsite.dk
Subject: Re: math, percentage
Date: Sat, 31 Dec 2005 18:22:14 +1100	[thread overview]
Message-ID: <op.s2mz3cxn6k1y1x@localhost.localdomain> (raw)
In-Reply-To: <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@aljex.com> 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@aljex.com  --  http://www.aljex.com/bkw/
> +++++[>+++[>+++++>+++++++<<-]<-]>>+.>.+++++.+++++++.-.[>+<---]>++.
> filePro  BBx    Linux  SCO  FreeBSD    #callahans  Satriani  Filk!
>



  reply	other threads:[~2005-12-31  7:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-31  6:56 Brian K. White
2005-12-31  7:22 ` Eric Mangold [this message]
2005-12-31  7:25 ` Dan Nelson
2005-12-31 20:44   ` Brian K. White
     [not found]     ` <488030720601041505g7a9aee72nc8ebcf1bde13b3a4@mail.gmail.com>
2006-01-05  4:43       ` Brian K. White
2006-01-05 23:54         ` Jonathan Hankins

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=op.s2mz3cxn6k1y1x@localhost.localdomain \
    --to=teratorn@world-net.net \
    --cc=brian@aljex.com \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).