Sponsored Content
Top Forums Shell Programming and Scripting Compare float value with single decimal Post 302503531 by danmero on Thursday 10th of March 2011 10:11:05 PM
Old 03-10-2011
Quote:
Originally Posted by alvin0618
No value display, may i know why?
Yes Smilie
Quote:
Originally Posted by alvin0618
Code:
#!/bin/bash
declare $(awk '$1>=5.1 && $1<=10{r1++}$1>=10 && $1<=15{r2++}END{print "range1_count="r1,"range2_count="r2}' /export/home/alvin/test.txt)
echo $range1_count
echo $range2_count

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

compare decimal numbers

Hi anyone, i need to compare two decimal numbers i thought that it could be do it with if but... :( So, i'm writing in csh and i really apreciate if anyone can help me if ( $ppl_kn <= $ppl_wb ) then echo "############# KNdiscount model has the lowest perplexity" set... (5 Replies)
Discussion started by: tmxps
5 Replies

2. Programming

math.h: float ceilf(float x)

Good morning, I'm testing the use of ceilf: /*Filename: str.c*/ #include <stdio.h> #include <math.h> int main (void) { float ceilf(float x); int dev=3, result=0; float tmp = 3.444f; printf("Result: %f\n",ceilf(tmp)); return 0; } (1 Reply)
Discussion started by: jonas.gabriel
1 Replies

3. Shell Programming and Scripting

Compare integer value with decimal

Hi all, I have a issue... Is it possible to compare integer value with decimal value. If it is not possible,then how can i compare 2 decimal values in born shell.thanks! (3 Replies)
Discussion started by: MARY76
3 Replies

4. UNIX for Dummies Questions & Answers

Compare 2 files for a single column and output differences

Hi, I have a column in 2 different files which i want to compare, and output the results to a different file. The columns are in different positions in those 2 files. File 1 the column is in position 10-15 File 2 the column is in position 15-20 Please advise Thanks (1 Reply)
Discussion started by: samit_9999
1 Replies

5. UNIX for Dummies Questions & Answers

How to compare null and space using single if condition

Hi I have a input file with many fields and each filed will be with in double quotes(""). i want to check fields contains balnk,null or space using condition using if. when i write code as below for if condition its not working a=`awk -F ',' '{gsub("\"", "", $1);'NF==0';printf $1}'... (3 Replies)
Discussion started by: jayakumarrt
3 Replies

6. UNIX for Dummies Questions & Answers

compare decimal and integer values in if in bash shell

i need to do camparisions like the below. For the case when first=10 and second=9.9 the scripts displays process failed. I need to be able to convert the values to integer before doing the comparision. Like 9.9 should be rounded over to 10 before doing comparision. Please advice how can... (3 Replies)
Discussion started by: nehagupta
3 Replies

7. Shell Programming and Scripting

bin bash decimal compare

I need decimal comparing with if. Check if apache version is less than 2.2.17. I tried this and not working. #!/bin/bash apachever=`/usr/local/apache/bin/httpd -v | head -1 | awk '{print $3}' |cut -d/ -f 2` if ]; then echo "Apache version less than 2.2.17" else ... (7 Replies)
Discussion started by: anil510
7 Replies

8. Shell Programming and Scripting

How compare decimal values?

I have 2 files say tp1.txt and tp2.txt having following data cat tp1.txt abc,2.20,IN20 acb,3.15,DN10 bca,3,RD10 cat tp2.txt alv,1.00,IN20 aaa,4.05,DD10 abb,5.50,RD12 i want to compare the values on 2nd field of both the file, if value of first tp1.txt is greater than value... (3 Replies)
Discussion started by: ranabhavish
3 Replies

9. Shell Programming and Scripting

How to compare decimal values in bash?

Hi, I am facing some error while doing the comparision between 2 decimal values in bash. Pl help me out. I have tried using below scripts. But its giving me error. 1)amt=12.3 opn_amt=12.5 var=$(awk 'BEGIN{ print "'$amt'"<"'$opn_amt'" }') if ;then echo "correct" else echo "Wrong"... (3 Replies)
Discussion started by: Siba Tripathy
3 Replies

10. Shell Programming and Scripting

Compare columns in a single file

i have the following files (all separated by tabs): file 1.txt 1 yes 2 no 3 yes 4 yes file 2.txt a no b no c yes d no i combine the above files in file 3 which looks like file 3.txt 1 yes a no 2 no b no 3 yes c yes 4 yes d no now, i need to compare the values between column 2... (3 Replies)
Discussion started by: msonoth
3 Replies
shevek::relative_time(3)				     Library Functions Manual					  shevek::relative_time(3)

NAME
shevek::relative_time - Time interval. SYNOPSIS
#include <time.hh> Public Member Functions relative_time () The default constructor creates an interval of 0. relative_time (timetype days, int hours, int minutes, int seconds, int nanoseconds=0) Construct an interval of a given size. relative_time (timetype seconds, unsigned nanoseconds) Fast constructor. relative_time operator+ (relative_time that) const Add two intervals. absolute_time operator+ (absolute_time that) const Add an interval to a moment. relative_time operator- (relative_time that) const Subtract two intervals. relative_time operator- () const Negate an interval. relative_time operator* (float c) const Scale an interval. relative_time operator/ (float c) const Scale an interval. relative_time operator% (relative_time that) const Modulo operator for two intervals. double operator/ (relative_time that) const Division of two intervals. relative_time & operator+= (relative_time that) Add an interval. relative_time & operator-= (relative_time that) Subtract an interval. relative_time & operator*= (float c) Scale the interval. relative_time & operator/= (float c) Scale the interval. relative_time & operator%= (relative_time that) Modulo. bool operator< (relative_time that) const Compare with another interval. bool operator> (relative_time that) const Compare with another interval. bool operator<= (relative_time that) const Compare with another interval. bool operator>= (relative_time that) const Compare with another interval. bool operator== (relative_time that) const bool operator!= (relative_time that) const unsigned nanoseconds () const Number of nanoseconds. unsigned seconds () const Number of seconds. unsigned minutes () const Number of minutes. unsigned hours () const Number of hours. unsigned days () const Number of days. bool isnegative () const Is this a negative interval? timetype total () const Total number of seconds, as encoded. Static Public Member Functions static void set_digits (unsigned num) Set number of digits to use when printing (for fractions of seconds). static unsigned get_digits () Get the number of digits that is used when printing. Friends std::ostream & operator<< (std::ostream &s, relative_time t) Write the interval to a std::ostream. Detailed Description Time interval. Constructor &; Destructor Documentation shevek::relative_time::relative_time (timetypeseconds, unsignednanoseconds) Fast constructor. This directly fills the members and is therefore slightly faster than the other constructors. However, the others aren't really slow either. Member Function Documentation bool shevek::relative_time::operator!= (relative_timethat) const Compare two intervals. Note that this is rarely a useful operation, because minor errors may be introduced by computations. bool shevek::relative_time::operator== (relative_timethat) const Compare two intervals. Note that this is rarely a useful operation, because minor errors may be introduced by computations. Author Generated automatically by Doxygen for libshevek from the source code. libshevek Fri May 11 2012 shevek::relative_time(3)
All times are GMT -4. The time now is 11:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy