The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to use expr saikumarm80 Red Hat 3 01-05-2009 03:52 PM
problem with expr command ravi raj kumar UNIX for Dummies Questions & Answers 8 09-03-2007 05:59 AM
expr problem kotasateesh UNIX for Dummies Questions & Answers 4 09-03-2007 03:27 AM
expr Nathe UNIX for Dummies Questions & Answers 5 01-22-2004 07:49 PM
how do I get the value of expr with ksh krishna UNIX for Advanced & Expert Users 3 08-26-2001 02:51 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-31-2007
kotasateesh kotasateesh is offline
Registered User
  
 

Join Date: Aug 2005
Posts: 39
expr problem

Hi,
in my ksh script

expr 22 / 10 results as 2
but the actual result expected in 2.2.
how do i get that result. Please help

Thanks,
  #2 (permalink)  
Old 08-31-2007
fazliturk fazliturk is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 45
/ is integer division
% modulus
may be you can use awk

awk 'BEGIN{print (22/10) }'

with parameters

awk -v a=$1 -v b=$2 '{print (a/b) }'

or

echo $number |awk '{print ($1/10)}'

Last edited by fazliturk; 08-31-2007 at 08:38 AM..
  #3 (permalink)  
Old 08-31-2007
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,537
expr works with integers.
Code:
 # echo 'scale=2;22/10' |bc
2.20
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:12 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0