Sponsored Content
Top Forums Shell Programming and Scripting Check if the input is number or text? Post 302370370 by waso on Wednesday 11th of November 2009 08:02:07 AM
Old 11-11-2009
CPU & Memory Check if the input is number or text?

i have to check if is input number or text, i case that is text then exit script

exaple is hrere, but is not working

Code:
check_it()
{
    if [ "$1" != +([a-zA-Z]) ]
        then        
        if (( $1 > 0 && $1 < 13 )); 
            then
                echo "input number is ok"
        else
                echo "number not ok"
                exit 1
        fi
    else
      echo "just numbers please"
      exit 1
    fi
}

case $1 in
        0*)             echo "sorry, no leading zeroes"
                        exit 1;;
        "")             echo "input parameter is required"
                        exit 1;;
esac

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

What can i do to check that the input is all alphabet.. ?

What can i do to check that the input is all alphabet.. ? (4 Replies)
Discussion started by: XXXXXXXXXX
4 Replies

2. Shell Programming and Scripting

Check on Input

HI all, I would like to know how the user can be restricted for entering only the number and not characters in sheel scripts.. Suppose code is like this echo 'Enter the number' read Value Now user may enter 'a' as value... But i want to disallow him for entering characters other than... (3 Replies)
Discussion started by: dhananjaysk
3 Replies

3. UNIX for Dummies Questions & Answers

check the input

how to check whether a given input is a number or a string? (1 Reply)
Discussion started by: Shilpi
1 Replies

4. Shell Programming and Scripting

Bash : how do i check the user input and make sure is only chracter or only number ?

Bash : how do i check the user input and make sure is only character or only number ? (7 Replies)
Discussion started by: CheeSen
7 Replies

5. Shell Programming and Scripting

shell script to take input from a text file and perform check on each servers and copy files

HI all, I want to script where all the server names will be in a text file like server1 server2 server3 . and the script should take servernames from a text file and perform copy of files if the files are not present on those servers.after which it should take next servername till the end of... (0 Replies)
Discussion started by: joseph.dmello
0 Replies

6. UNIX for Dummies Questions & Answers

Check Column corresponding to input

I have a file which extracts data from an HTML file For Eg HTML file contains: New York;ABC;145;Yes;YES;No New York;BCD;113;Yes;YES;No New York;NAS;63;Yes;YES;No ------------------------ London-48;CBT;16;Yes;YES;No London-48;CME;17;Yes;YES;No London-48;EUR;52;Yes;YES;No... (7 Replies)
Discussion started by: newkid.7955
7 Replies

7. Shell Programming and Scripting

Check whether input is numeric

Hello there, find below for my code first: $pdp_asaba=`cat /tmp/temp_total | grep asaba | sed 's/*//g'` if ]] then pdp_asaba=0 fi $pdp_abuja=`cat /tmp/temp_total | grep abuja | sed 's/*//g'` if ]] then pdp_abuja=0 fi $pdp_ojota=`cat /tmp/temp_total | grep ojota | sed 's/*//g'` if ... (3 Replies)
Discussion started by: infinitydon
3 Replies

8. UNIX for Dummies Questions & Answers

Search String, Out matched text and input text for no match.

I need to search a string for some specific text which is no big deal using grep. My problem is when the search fails to find the text. I need to add text like "na" when my search does not match. I have tried this command but it does not work when I put the command in a loop in a bash script: ... (12 Replies)
Discussion started by: jojojmac5
12 Replies

9. Shell Programming and Scripting

awk to skip lines find text and add text based on number

I am trying to use awk skip each line with a ## or # and check each line after for STB= and if that value in greater than or = to 0.8, then at the end of line the text "STRAND BIAS" is written in else "GOOD". So in the file of 4 entries attached. awk tried: awk NR > "##"' "#" -F"STB="... (6 Replies)
Discussion started by: cmccabe
6 Replies

10. Shell Programming and Scripting

Search last column of INPUT.txt in TABLEs text and add correspond columns to INPUT.txt

Hi dears i use bash shell i have INPUT.txt like this number of columns different in one some row have 12 , some 11 columns see last column INPUT.txt CodeGender Age Grade Dialect Session Sentence Start End Length Phonemic Phonetic 63 M 27 BS/BA TEHRANI 3 4 298320 310050... (2 Replies)
Discussion started by: alii
2 Replies
DXmCreateScrolledCSText(3X)											       DXmCreateScrolledCSText(3X)

NAME
DXmCreateScrolledCSText - Creates a compound string text widget with scroll bars. SYNOPSIS
Widget DXmCreateScrolledCSText( Widget parent, char *name, Args *args, Cardinal num_args ); PARAMETERS
The identifier (widget ID) of the parent widget. The name of the created widget. The application override argument list. The number of arguments in the application override argument list. DESCRIPTION
The DXmCreateScrolledCSText routine creates a compound string text widget with scroll bars. The routine uses the same arguments and resources as the DXmCreateCSText routine to create a compound string text widget but uses the following resources to create horizontal and vertical scroll bars for the widget as well: ------------------------------------------------------------------- Resource Description ------------------------------------------------------------------- XmNscrollHorizontal Controls whether a scroll bar that allows the user to scroll through text horizontally is added to the compound string text window. XmNscrollTopSide Controls whether the horizontal scroll bar is positioned at the top of the compound string text window. XmNscrollVertical Controls whether a scroll bar that allows the user to scroll through text vertically is added to the compound string text window. XmNscrollLeftSide Controls whether the vertical scroll bar is placed on the left side of the compound string text window. ------------------------------------------------------------------- Inherited Resources The DXmCreateScrolledCSText routine inherits behaviour and resources from the following superclasses: Core Resource Set XmPrimitive Resource Set DXmScrolledCSText Resource Set RETURN VALUES
The identifier (widget ID) of the created compound string text widget. SEE ALSO
DXmCreateCSText(3X) DXmCreateScrolledCSText(3X)
All times are GMT -4. The time now is 03:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy