LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 10-01-2004, 05:32 AM   #1
graziano1968
Member
 
Registered: Sep 2004
Posts: 223

Rep: Reputation: 30
bash and strings


Hi

I am writing with bash a simple program (I am not an expert of bash).


why

#a=`expr 1 / 2`;echo "$a"

return 0 , instead of 0.5 ?



Thank you!

Last edited by graziano1968; 10-01-2004 at 05:45 AM.
 
Old 10-01-2004, 06:24 AM   #2
majalee
Member
 
Registered: Jul 2004
Location: India
Distribution: Ubuntu / OpenSuse
Posts: 54

Rep: Reputation: 15
hi,

expr does not handle decimals.. what u will have to do is this :


$ a=`echo 1/2 | bc -l`; echo $a

and the result will be :

.50000000000000000000

enjoy !!

majalee
 
Old 10-01-2004, 06:50 AM   #3
graziano1968
Member
 
Registered: Sep 2004
Posts: 223

Original Poster
Rep: Reputation: 30
Quote:
Originally posted by majalee
hi,

expr does not handle decimals.. what u will have to do is this :


$ a=`echo 1/2 | bc -l`; echo $a

and the result will be :

.50000000000000000000

enjoy !!

majalee
great thanks !
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script help (arrays and strings from files) nkoplm Programming 14 12-02-2005 09:50 AM
how to find duplicate strings in vertical column of strings markhod Programming 7 11-02-2005 04:04 AM
Bash scripting: column-ize file of varying length strings Quantum0726 Programming 4 08-13-2005 06:19 PM
BASH: Output everything between two strings systemparadox Programming 2 12-18-2004 10:26 AM
adding strings in bash FireAge Linux - General 4 03-11-2003 10:57 AM


All times are GMT -5. The time now is 10:12 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration