Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Bash Floating Number Variables Comparision Post 302830253 by Ariean on Monday 8th of July 2013 11:16:44 AM
Old 07-08-2013
Bash Floating Number Variables Comparision

I am trying to compare the floating number variables but i am receiving an error, can you please help what is wrong. Thank you.

Code:
#!/bin/bash

var1=100.25
var2=100.25

if (( $var1 == $var2 )); then
        echo "Matching"
else
        echo "Not Matching"
fi

Error:
Code:
./number.sh: line 6: ((: 100.25 == 100.25 : syntax error: invalid arithmetic operator (error token is ".25 == 100.25 ")
Not Matching

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Number comparision in AWK

Hi, I have a file like this. "2006","10",25,"U","1129","32","C",0,0,0,0,0,0,0,0,0,0,0,0,352,16,4,0,0,0,0,0,"80",,1 "2006","11",25,"U","1148","32","C",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"80",,2 "2006","14",25,"U","1149","10","C",0,0,0,0,0,0,0,0,0,0,0,0,560,12,0,0,0,0,0,0,"80",,3... (1 Reply)
Discussion started by: vskr72
1 Replies

2. Shell Programming and Scripting

using bc with floating point number in files

Hi, I' using bash and I would like to use "bc" to compute the ratio of of two numbers and assign the ratio to a variable. The numbers are in a file, e.g. 196.304492 615.348986 Any idea how to do it? N.B. I cannot change the file to have 196.304492 / 615.348986 as the file is produced by... (14 Replies)
Discussion started by: f_o_555
14 Replies

3. Shell Programming and Scripting

HELP: compare floating point variables??

Hi All, I got this script that pulls the Amps value from our RPC's , I basiclly want to compare the valued with a "limit" value -- if the numbers match or are greater than the definded value ...do something. My problem is I cant seem to figure out how to compare floating points... here is... (1 Reply)
Discussion started by: zeekblack
1 Replies

4. Shell Programming and Scripting

Defining Dynamic Number of Variables in a Bash Script

Code: $ cat test.bash #!/bin/bash job=$1 steps=$2 num=$(echo "$@" | wc -w) Example Submission: $ ./test.bash BS01 3 1 2 3 What: (2 Replies)
Discussion started by: mkastin
2 Replies

5. Shell Programming and Scripting

floating point variables korn shell

Hi I'm not using Korn93 but want to use floating point variable. Is there any solution to do that ? thx for help. ---------- Post updated at 02:28 PM ---------- Previous update was at 12:38 PM ---------- I have the following peace of code: for n in `cat log.January.1.array` do ... (3 Replies)
Discussion started by: presul
3 Replies

6. Shell Programming and Scripting

[BASH] Regex for floating point number

Hey again, I have a basic regex that tests if a number is a float. Thank you. (5 Replies)
Discussion started by: whyte_rhyno
5 Replies

7. Shell Programming and Scripting

How to compare floating variables , integer value expected?

I am running some commands and I am trying to get an output into a variable. I am having problem when I try to put that value in while loop, it says integer value expected. What's the best way to accomplish this remaining=$(symclone -sid XXX -f Clone_test query | grep MB | awk '{print... (1 Reply)
Discussion started by: rajsan
1 Replies

8. Shell Programming and Scripting

Convert floating point to a number

Hello Guys, I have a floating point number 1.14475E+15 I want to convert this number in to full number (Integer or Big integer). I tried couple of functions it did not work. When I use INT=${FLOAT/.*} I am getting value as 1. I don't want a truncated value #!/bin/bash #... (9 Replies)
Discussion started by: skatpally
9 Replies

9. Shell Programming and Scripting

Bash script accepting variables in valid number format

Hi Experts I would like to ask if there is a way to validate if the variable passed is in this kind of sample format "06-10" or "10-01". It was really a challenge to me on how to start and echnically the "6-10" stands for "June 10" and "10-01" stands as "October 1", overall it needs to have ... (3 Replies)
Discussion started by: ersan-poguita
3 Replies

10. Shell Programming and Scripting

Bash script to print the smallest floating point number in a row that is not 0

Hello, I have often found bash to be difficult when it comes to floating point numbers. I have data with rows of tab delimited floating point numbers. I need to find the smallest number in each row that is not 0.0. Numbers can be negative and they do not come in any particular order for a given... (9 Replies)
Discussion started by: LMHmedchem
9 Replies
symlink(3)						User Contributed Perl Documentation						symlink(3)

NAME
PerlIO::via::symlink - PerlIO layers for create symlinks SYNOPSIS
open $fh, '>:via(symlink)', $fname; print $fh "link foobar"; close $fh; DESCRIPTION
The PerlIO layer "symlink" allows you to create a symbolic link by writing to the file handle. You need to write C"link $name" to the file handle. If the format does not match, "close" will fail with EINVAL. TEST COVERAGE
----------------------------------- ------ ------ ------ ------ ------ ------ File stmt branch cond sub time total ----------------------------------- ------ ------ ------ ------ ------ ------ blib/lib/PerlIO/via/symlink.pm 100.0 100.0 n/a 100.0 100.0 100.0 Total 100.0 100.0 n/a 100.0 100.0 100.0 ----------------------------------- ------ ------ ------ ------ ------ ------ AUTHORS
Chia-liang Kao <clkao@clkao.org> COPYRIGHT
Copyright 2004-2005 by Chia-liang Kao <clkao@clkao.org>. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See <http://www.perl.com/perl/misc/Artistic.html> perl v5.16.2 2005-03-01 symlink(3)
All times are GMT -4. The time now is 01:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy