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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:16:35+00:00 2026-05-20T12:16:35+00:00

How can I validate numeric input arguments to a tcsh script? #!/usr/bin/tcsh if (

  • 0

How can I validate numeric input arguments to a tcsh script?

#!/usr/bin/tcsh

if ( $1 < 0.0 ) then
    echo "ERROR: first input argument is less than zero."
    exit 1
endif

The above snippet shows what I’m trying to do but doesn’t work. I have tried MANY combinations based on using the expr command or the @ operator to no avail. The man page and the web have turned up nothing yet. No matter what I try I keep getting errors like “Badly formed number” or “set: Variable name must begin with a letter”.

Is there a tcsh-ish way of doing this? I could certainly hack something up using awk or watever but that seems kind of silly.

  • 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-20T12:16:36+00:00Added an answer on May 20, 2026 at 12:16 pm

    Tcsh doesn’t do floats. You can use bc or awk:

    #!/usr/bin/tcsh
    if ( `echo "$1 < 0.0" | bc` == 1 ) then
        echo "ERROR: first input argument is less than zero."
        exit 1
    endif
    

    or

    #!/usr/bin/tcsh
    if ( `awk -v "val=$1" 'BEGIN {print val < 0.0}'` == 1 ) then
        echo "ERROR: first input argument is less than zero."
        exit 1
    endif
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I validate the user input by using scanf. Right now I have
I know that I can validate an input field by adding a inputmaskvalidator tag.
var rules = Numeric - percentage Informational; How do I validate an input based
What is a good regular expression that can validate a text string to make
I'm looking for a plugin for jQuery that can validate as a key is
I'm writing a quick Rails app and was wondering how I can validate the
How can I validate that my ASPNET AJAX installation is correct. I have Visual
Using the jQuery Validation plugin and AJAX, how can I validate the contents of
I have been seriously disappointed with WPF validation system. Anyway! How can I validate
Can anybody help me to build an XSD file to validate XMLs like these:

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.