Nelson Serafica | 1 Dec 02:49
Picon
Favicon

How to display remainder in Bash script

I'm trying to create a script that will convert b/s to kb/s. To convert to kb/s, I must divide it to 1000 b/s. However, the answer does not contain the remainder. When I do "expr 5 / 3", it shows only 1 (suppose to be 1.6). Doesn't show the remainder .6.

I search in Google and it says the "%" is remainder of a division. But when I do expr 5 % 3, it shows "2". It suppose to be 6, am I right?


Any inputs,



--- Forever Linux Newbie

Organic foods - just how healthy is health food?
Be a better foodie
Find out at Yahoo! Answers
_________________________________________________
Philippine Linux Users' Group (PLUG) Mailing List
plug@... (#PLUG @ irc.free.net.ph)
Read the Guidelines: http://linux.org.ph/lists
Searchable Archives: http://archives.free.net.ph
Picon

Re: How to display remainder in Bash script

On Dec 1, 2007 9:49 AM, Nelson Serafica <ntserafica@...> wrote:
>
> I search in Google and it says the "%" is remainder of a division. But when
> I do expr 5 % 3, it shows "2". It suppose to be 6, am I right?

No, you're not: '%' is modulo (remainder of integer division). And to
convert a byte to kilobyte, divide by 1024. (At least that was what we
were taught waaay back when I was in school.)

--

-- 
Ian Dexter R. Marquez
http://feeds.iandexter.net/Coredump
_________________________________________________
Philippine Linux Users' Group (PLUG) Mailing List
plug@... (#PLUG @ irc.free.net.ph)
Read the Guidelines: http://linux.org.ph/lists
Searchable Archives: http://archives.free.net.ph

Picon
Gravatar

Re: How to display remainder in Bash script

Hi Nelson,

The remainder of 5 when divided by 3 is indeed 2.  And (if I'm not mistaken) bash doesn't handle floats.  You can use other scripting languages though, like python and it should be easy there.

Hope this helps,
Allister

On Dec 1, 2007 2:49 AM, Nelson Serafica <ntserafica <at> yahoo.com> wrote:
I'm trying to create a script that will convert b/s to kb/s. To convert to kb/s, I must divide it to 1000 b/s. However, the answer does not contain the remainder. When I do "expr 5 / 3", it shows only 1 (suppose to be 1.6). Doesn't show the remainder .6.

I search in Google and it says the "%" is remainder of a division. But when I do expr 5 % 3, it shows "2". It suppose to be 6, am I right?


Any inputs,



--- Forever Linux Newbie

Organic foods - just how healthy is health food?
Be a better foodie
Find out at Yahoo! Answers

_________________________________________________
Philippine Linux Users' Group (PLUG) Mailing List
plug <at> lists.linux.org.ph (#PLUG <at> irc.free.net.ph)
Read the Guidelines: http://linux.org.ph/lists
Searchable Archives: http://archives.free.net.ph



--
Dr. Allister Levi Sanchez ( sanchez <at> llr.in2p3.fr / allister.sanchez <at> gmail.com )
CNRS Postdoctoral Research Associate
Laboratoire Leprince-Ringuet, École Polytechnique, 91128 Palaiseau CEDEX, France
_________________________________________________
Philippine Linux Users' Group (PLUG) Mailing List
plug@... (#PLUG @ irc.free.net.ph)
Read the Guidelines: http://linux.org.ph/lists
Searchable Archives: http://archives.free.net.ph
andrelst | 1 Dec 03:22
Picon

Re: How to display remainder in Bash script

expr only does integers, which the man pages in Linux sadly omits.
Solaris explicitly says it in the man page that it's only for
integers.

go for bc if you want remainders:

$ echo 5 / 3 | bc -l
1.66666666666666666666

-- 
regards,
Andre | http://www.varon.ca

On Nov 30, 2007 8:49 PM, Nelson Serafica <ntserafica@...> wrote:
>
>
> I'm trying to create a script that will convert b/s to kb/s. To convert to
> kb/s, I must divide it to 1000 b/s. However, the answer does not contain the
> remainder. When I do "expr 5 / 3", it shows only 1 (suppose to be 1.6).
> Doesn't show the remainder .6.
>
> I search in Google and it says the "%" is remainder of a division. But when
> I do expr 5 % 3, it shows "2". It suppose to be 6, am I right?
>
>
> Any inputs,
_________________________________________________
Philippine Linux Users' Group (PLUG) Mailing List
plug@... (#PLUG @ irc.free.net.ph)
Read the Guidelines: http://linux.org.ph/lists
Searchable Archives: http://archives.free.net.ph

thad | 1 Dec 04:01
Picon

DJB Releases All Source to Public Domain

I know a lot on this group are big fan and user of DJB's softwares.

http://linux.slashdot.org/article.pl?sid=07/11/30/0430201

--

-- 
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sometimes truth is stranger than fiction
-bad religion-
http://www.bloglines.com/blog/mailist
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I don't think the computers will take over the world. I have a bucket of water.
_________________________________________________
Philippine Linux Users' Group (PLUG) Mailing List
plug@... (#PLUG @ irc.free.net.ph)
Read the Guidelines: http://linux.org.ph/lists
Searchable Archives: http://archives.free.net.ph

Michael Tinsay | 1 Dec 04:05
Picon
Favicon

Re: Linux compat listing for phil computer shops



>----- Original Message ----
>From: Roberto Verzola <rverzola-DBoORF5nt1Adnm+yROfE0A@public.gmane.org>
>To: Philippine Linux Users' Group (PLUG) Technical Discussion List <plug-cunTk1MwBs8iFSDQTTA3ONd+tgCGH7ND@public.gmane.org>
>Sent: Thursday, November 29, 2007 4:55:24 PM
>Subject: [plug] Linux compat listing for phil computer shops
>
>...
>
>Yes, hp... But the customer wants the Samsung because its cheaper. We still
>need to answer the question: will it work with Linux?
>...

We've checked on Samsung printers before.  Back then, official support from Samsung is non-existent.  But I think Samsung printers do accept either Postscript or HP PCL.

>How do we go about this? I suggest that a PLUG volunteer come forward (I know
>I made the orig suggestion, but I can't be that volunteer sorry) who will
>take responsibility to move this project forward (have the wiki ready, get
>needed info from PLUG members, hassle the PLUG directors for some operating
>funds, form a committee, etc.)

Maybe when the PLUG website is back up, maybe we can have a specific wiki page(s) for your suggestion.


--- mike t.






My posts are too long, sorry.

Regards to all,

Obet
_________________________________________________
Philippine Linux Users' Group (PLUG) Mailing List
plug-cunTk1MwBs8iFSDQTTA3ONd+tgCGH7ND@public.gmane.org (#PLUG <at> irc.free.net.ph)
Read the Guidelines: http://linux.org.ph/lists
Searchable Archives: http://archives.free.net.ph

_________________________________________________
Philippine Linux Users' Group (PLUG) Mailing List
plug@... (#PLUG @ irc.free.net.ph)
Read the Guidelines: http://linux.org.ph/lists
Searchable Archives: http://archives.free.net.ph
Nelson Serafica | 1 Dec 05:19
Picon
Favicon

Re: How to display remainder in Bash script


 I'm using bc and it is ok. The problem is I cannot put a number next to the output. I cannot command the echo with "-n parameters". After I get the value, I need to put another value next to it which is having an error

if [ $grep2a_1 -eq "1" ];
then
        echo -n "$time,"
        echo "scale=3; $com2_1 / 1000" | bc (If I change this line to echo -n "scale=3; $com2_1 / 1000" | bc, it has an error)
else
        echo "test"
fi




----- Original Message ----
From: andrelst <amvaron <at> gmail.com>
To: Philippine Linux Users' Group (PLUG) Technical Discussion List <plug-cunTk1MwBs8iFSDQTTA3ONd+tgCGH7ND@public.gmane.org>
Sent: Saturday, December 1, 2007 10:22:13 AM
Subject: Re: [plug] How to display remainder in Bash script

expr only does integers, which the man pages in Linux sadly omits.
Solaris explicitly says it in the man page that it's only for
integers.

go for bc if you want remainders:

$ echo 5 / 3 | bc -l
1.66666666666666666666

--
regards,
Andre | http://www.varon.ca

On Nov 30, 2007 8:49 PM, Nelson Serafica <ntserafica-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:
>
>
> I'm trying to create a script that will convert b/s to kb/s. To convert to
> kb/s, I must divide it to 1000 b/s. However, the answer does not contain the
> remainder. When I do "expr 5 / 3", it shows only 1 (suppose to be 1.6).
> Doesn't show the remainder .6.
>
> I search in Google and it says the "%" is remainder of a division. But when
> I do expr 5 % 3, it shows "2". It suppose to be 6, am I right?
>
>
> Any inputs,
_________________________________________________
Philippine Linux Users' Group (PLUG) Mailing List
plug-cunTk1MwBs8iFSDQTTA3ONd+tgCGH7ND@public.gmane.org (#PLUG <at> irc.free.net.ph)
Read the Guidelines: http://linux.org.ph/lists
Searchable Archives: http://archives.free.net.ph


Basic black. Runway ready, or just run-of-the-mill?
Be a better fashionista
Find out at Yahoo! Answers
_________________________________________________
Philippine Linux Users' Group (PLUG) Mailing List
plug@... (#PLUG @ irc.free.net.ph)
Read the Guidelines: http://linux.org.ph/lists
Searchable Archives: http://archives.free.net.ph
jopoy solano | 1 Dec 05:35
Picon

Re: PLUG Meeting Notes 11.09.07

Hi Gary,

You have my support. Mabuhay ka!

'Jopoy

On Nov 29, 2007 6:25 PM, Allister Levi Sanchez
<allister.sanchez@...> wrote:
> Hi Gary,
>
> It's not everyday that we actually see someone rise to the occasion.
>
> I wish you success in your efforts.
>
> Cheers,
> Allister
> --
> Dr. Allister Levi Sanchez ( sanchez@... /
> allister.sanchez@... )
> CNRS Postdoctoral Research Associate
> Laboratoire Leprince-Ringuet, École Polytechnique, 91128 Palaiseau CEDEX,
> France
> http://allistersanchez.blogspot.com
> http://allisterx.blogspot.com
>
> _________________________________________________
> Philippine Linux Users' Group (PLUG) Mailing List
> plug@... (#PLUG @ irc.free.net.ph)
> Read the Guidelines: http://linux.org.ph/lists
> Searchable Archives: http://archives.free.net.ph
>
_________________________________________________
Philippine Linux Users' Group (PLUG) Mailing List
plug@... (#PLUG @ irc.free.net.ph)
Read the Guidelines: http://linux.org.ph/lists
Searchable Archives: http://archives.free.net.ph

Picon
Gravatar

[OT] Fwd: [AS2-Pilipinas:213] LINUX TRAINING CENTERS AND FOSS DEVELOPERS

---------- Forwarded message ----------
From: Francis <francis.sarmiento3@...>
Date: Dec 1, 2007 3:25 PM
Subject: [AS2-Pilipinas:213] LINUX TRAINING CENTERS AND FOSS DEVELOPERS
To: AsiaSource2-Pilipinas <asiasource2-pilipinas@...>

Hello All!

We are building a list of Linux training centers and FOSS Developers
in the ASEAN+3 region for the UNDP-International Open Source Network.
If in case you know of any, kindly email to us the training center URL
at asean3[at]iosn[dot]net.

ASEAN+3 geographical mandate include:  Brunei, Cambodia, Indonesia,
Lao PDR, Malaysia, Myanmar, Philippines, Singapore, Thailand, and
Vietnam with China, Japan and South Korea.

As for the FOSS developers, please do supply the following:

PERSONAL INFO:
Country of residence and/or work:
Name:
Position:
Company:
Blog:
Company URL:

List of FOSS PROJECTS:
(For as long as you have the permission of the company whom you
created it for, that you will be emailing the project info to us)
Title:
Description:
Screenshots:

List of FOSS TRAININGS/SEMINARS/EVENTS:
What:
When:
Where:
Who Organized:
URL:
Pics:

Please email to us the details in the format most convenient to you.

Thank you so much.

P.S.  Please disseminate
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "AsiaSource2-Pilipinas" group.
To post to this group, send email to asiasource2-pilipinas@...
To unsubscribe from this group, send email to
asiasource2-pilipinas-unsubscribe@...
For more options, visit this group at
http://groups.google.com/group/asiasource2-pilipinas?hl=en
-~----------~----~----~----~------~----~------~--~---

--

-- 
Diana Jayne C. Gonzales (0xB83AF9B0)
http://godiane.net/
_________________________________________________
Philippine Linux Users' Group (PLUG) Mailing List
plug@... (#PLUG @ irc.free.net.ph)
Read the Guidelines: http://linux.org.ph/lists
Searchable Archives: http://archives.free.net.ph

Danny Ching | 1 Dec 11:59
Picon
Gravatar

Re: 64bit vs. 32bit

WOW! Thanks guys! Learned a lot! Although misunderstandings are always best avoided. I am actually proud that PLUGgers actually take giving advice this seriously. MABUHAY ang open source, mabuhay ang open community!

PS I actually bragged to my wife about the lists' enthusiasm to my question. Very reassuring.

On Nov 30, 2007 9:13 PM, Kelsey Hartigan Go < kelsey.hartigan.go-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:


On Nov 27, 2007 5:10 PM, Orlando Andico <orly.andico-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
On Nov 27, 2007 4:34 PM, Michael Tinsay <tinsami1-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:
..
> A 64-bit processor means that it can fetch memory 64 bits at a time compared
> to a 32-bit machine which fetches 32 bits at a time.  Offhand, fetching from
> main memory to cache should take less time.

Yes -- but -- ultimately you are limited by how wide is the bus width
to main memory. Even 32-bit Intel CPU's have a 64-bit bus width to the
main memory.

Also, working on 64 bits at a time means that a machine word consumes
8 bytes instead of 4 bytes. So you can only store half the number of
words in the cache. This is why I said the cache is effectively
halved.

You're talking mostly of the code stream...however, when it's data stream you're talking about, like heavy sorting and the like, 64 bit is going to fly.



--

---
Kelsey Hartigan Go
Registered Linux user #5998
_________________________________________________
Philippine Linux Users' Group (PLUG) Mailing List
plug-cunTk1MwBs8iFSDQTTA3ONd+tgCGH7ND@public.gmane.org (#PLUG <at> irc.free.net.ph)
Read the Guidelines: http://linux.org.ph/lists
Searchable Archives: http://archives.free.net.ph



--
Regards,
Danny Ching
_________________________________________________
Philippine Linux Users' Group (PLUG) Mailing List
plug@... (#PLUG @ irc.free.net.ph)
Read the Guidelines: http://linux.org.ph/lists
Searchable Archives: http://archives.free.net.ph

Gmane