Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9112519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:45:18+00:00 2026-06-17T03:45:18+00:00

I am trying to perform a simple integer comparison in bash, which I am

  • 0

I am trying to perform a simple integer comparison in bash, which I am new to using, and my methods are causing an error. Any advice would be appreciated.

My basic logic is that I am reading in hurricane track points. There may be multiple entries for the same track_id, with different pressure values. What I want to do is store only one entry per track_id into the array track_id_poly; the case with the lowest pressure. So I am looping through each line, and attempting to compare the current pressure (for $int), with the previous track pressure ($int – 1), and if it is lower, replace the previous array value with the new lower pressure. I hope that makes sense. My code is below.

int=0
    while read track_id ppres_inter 
    do
      printf -v pres_inter "%.0f" "$pres_inter"
      echo pressure $pres_inter
      case $int in
      0)
        Track_id_poly[$int]=$track_id
        Pres_inter_poly[$int]=$pres_inter
        ((int=int+1)) ;;
      *)  
       if [[ $track_id == ${Track_id_poly[$int-1]} ]]
       then
         if (( $pres_inter -lt ${Pres_inter_poly[$int-1]} ))
         then
           Track_id_poly[$int-1]=$track_id
           Pres_inter_poly[$int-1]=$pres_inter
         fi
       else  
         Track_id_poly[$int]=$track_id
         Pres_inter_poly[$int]=$pres_inter
         ((int=int+1))
       fi ;;
      esac
    done <$file_poly
    int_poly=$int
    echo Number of polygon crossings from set $i is $int_poly

The line that is causing me problems is the integer comparison for $pres_inter.

if (( $pres_inter -lt ${Pres_inter_poly[$int-1]} ))

I get the following error:

line 41:  96800 -lt 98759 : syntax error in expression (error token is "98759 ")

Any tips to fix this problem would be appreciated. Probably a simple fix!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T03:45:19+00:00Added an answer on June 17, 2026 at 3:45 am

    The ((...)) operator does not accept the same syntax as the test, [..], or [[...]] commands. To compare two numbers in ((...)), you would use actual > or < symbols:

    $ (( 4 > 2 )) && echo '4 is bigger!'
    4 is bigger!
    

    See the ARITHMETIC EVALUATION section of the bash(1) man page for more information (or here).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to perform a simple jQuery AJAX attempt using either a .get()
I'm trying to perform some simple animations using CA layers on transparent window and
I am using JDK 7 and I am trying to perform a simple write-to-file
I'm trying to perform some super simple parsing o log files, so I'm using
I'm trying to perform a simple html request using jquery with the code below.
Im trying to perform simple calculations using jQuery but I'm getting NaN as result.
I'm trying to perform a simple animation using Cocoa. One button causes an image
I am trying to make simple SFTP connection and would like to perform simple
I'm trying perform a relatively basic TCP socket send/receive operation on Windows CE using
I'm trying to perform a fulltext search with codeigniters built in Active Record methods.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.