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

  • Home
  • SEARCH
  • 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 8032497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:24:20+00:00 2026-06-05T01:24:20+00:00

To test whether a variable is e.g. a number greater than 0, you would

  • 0

To test whether a variable is e.g. a number greater than 0, you would write:

((i > 0))

But how would I test if the variable is not a number greater than 0?

EDIT

Sorry for the typo, meant not a number greater than 0.

EDIT 2

Sry for the poor question. The value of the variable is passed as a commandline argument, so it may be a number or not. This also needs to be checked.

  • 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-05T01:24:21+00:00Added an answer on June 5, 2026 at 1:24 am

    For checking on not being number, you have to test with regex. I have used -5 instead 0 just to demonstrate more general case (My assumption is that you use integers):

    #!/bin/bash
    
    A=$1
    
    if [[ $A =~ ^[\-0-9]+$ ]] && (( A > -5)); then
      echo "A is number and is greater then -5"
    else
      echo "A is not a number or is <= -5"
    fi
    

    If you want to test for non-integers, you have to clarify in your question what is considered number.

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

Sidebar

Related Questions

I am trying to test to see whether a Javascript variable is undefined. You
Possible Duplicate: What's the correct way to test if a variable is a number
I'm trying to set up a test that will tell me whether a variable
Is there a way to test whether a variable holds a lambda ? The
I am trying to pass an extra variable, that determines whether or not the
How could one test whether a set of modules is installed, given the names
I want to test whether a certain string is contained in a short list
I was trying to test whether the Alt key was pressed. I had a
I want to test whether two languages have a string in common. Both of
How to test whether a node contains particular string or character using C# code.

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.