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 6372467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:14:35+00:00 2026-05-25T01:14:35+00:00

I am trying to check if a value I read from a text file

  • 0

I am trying to check if a value I read from a text file is zero:

[[ $(echo $line | cut -d" " -f5) -gt 0 ]] && [[ $(echo $line | cut -d" " -f7 | bc -l) -eq 0 ]]

With the first condition there is no problem because f5 are integers. The problem comes form the second condition. I receive this error message:

[[: 1.235: syntax error: invalid arithmetic operator (error token is ".235")

I have tried several suggestions I found in different forums such as using echo $line | cut -d" " -f7 | bc -l with and without double quotes, etc. However, the error persist. f7 is a positive number and is given with 3 decimal places. Removing decimals or approximating is not an option because I need the result to be exactly zero (0.000).

  • 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-05-25T01:14:36+00:00Added an answer on May 25, 2026 at 1:14 am

    Use a string comparison instead. Replace:

    -eq 0
    

    with:

    = '0.000'
    

    TZ:

    Script section from comment:

    for clus in $(ls *.cluster) ; do
        while read line ; do
            if [[ $(echo $line | cut -d" " -f11) -gt 0 ]] && [[ "$(echo $line | cut -d" " -f15 | bc -l)" = '0.000' ]] ; then
                cat $(echo $line | cut -d" " -f6).pdb >> test/$(echo $line | cut -d" " -f2)_pisa.pdb
            fi
        done < $clus
    done
    

    My pseudo-Python interpretation:

    for clus in *.cluster:
        for line in clus:
            fields = line.split(' ')
            # field numbers are counting from 1 as in cut
            if int(field 11) > 0 and str(field 15) == '0.000':
                fin_name = (field 6) + '.pdb'
                fout_name = (field 2) + '_pisa.pdb'
                cat fin_name >> fout_name
    

    Is that what you intended?

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

Sidebar

Related Questions

I'm trying to read a character represented by the hex value 0x80 from a
I am trying to read a value of a key from a dictionary like
I'm trying to read the contents of a text file into the attributes of
I'm trying to check if a form input has any value (doesn't matter what
I was trying to check out a project from SVN using Eclipse. I tried
I'm trying to check in jQuery if a div contains some text, and then
I am trying to retrieve particular parts of a string in a text file
I'm trying to read input from the terminal. For this, I'm using a BufferedReader.
I'm trying to change the value of a JComboBox, from an ActionListener, and having
I am trying to create a highchart line graph using data from a .csv

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.