Sponsored Content
Top Forums Shell Programming and Scripting Check if the input is number or text? Post 302370403 by waso on Wednesday 11th of November 2009 09:17:28 AM
Old 11-11-2009
Quote:
Originally Posted by fpmurphy
Not sure what you were trying to achieve with both the check_it function and the case statement. You can do it all using a case statement as shown in the following example
Code:
#!/usr/bin/bash

shopt -s extglob

INPUT="123456"

case $INPUT in
   ( +([[:digit:]]) )   echo "INPUT is all numbers" ;;
   *)                   echo "INPUT is not all numbers" ;;
esac

users execute script like this:
Code:
/app/av/test/test.sh 12

in script i have 2 more script that will execute if the input parameter $1 is correct

first i must check if is $1 number and not text
second $1 must be number betwin 1-12, and cant have leading zeroes for number 1-9

Last edited by waso; 11-11-2009 at 11:17 AM..
 

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
QwtTextLabel(3) 						 Qwt User's Guide						   QwtTextLabel(3)

NAME
QwtTextLabel - A Widget which displays a QwtText. SYNOPSIS
#include <qwt_text_label.h> Inherited by QwtLegendItem. Public Slots void clear () void setText (const QString &, QwtText::TextFormat textFormat=QwtText::AutoText) virtual void setText (const QwtText &) Public Member Functions virtual int heightForWidth (int) const int indent () const int margin () const virtual QSize minimumSizeHint () const QwtTextLabel (const QwtText &, QWidget *parent=NULL) QwtTextLabel (QWidget *parent=NULL) void setIndent (int) void setMargin (int) virtual QSize sizeHint () const const QwtText & text () const QRect textRect () const virtual ~QwtTextLabel () Protected Member Functions virtual void drawContents (QPainter *) virtual void drawText (QPainter *, const QRect &) virtual void paintEvent (QPaintEvent *e) Detailed Description A Widget which displays a QwtText. Constructor &; Destructor Documentation QwtTextLabel::QwtTextLabel (QWidget *parent = NULL) [explicit] Constructs an empty label. Parameters: parent Parent widget QwtTextLabel::QwtTextLabel (const QwtText &text, QWidget *parent = NULL) [explicit] Constructs a label that displays the text, text Parameters: parent Parent widget text Text QwtTextLabel::~QwtTextLabel () [virtual] Destructor. Member Function Documentation void QwtTextLabel::clear () [slot] Clear the text and all QwtText attributes. void QwtTextLabel::drawContents (QPainter *painter) [protected, virtual] Redraw the text and focus indicator. void QwtTextLabel::drawText (QPainter *painter, const QRect &textRect) [protected, virtual] Redraw the text. Reimplemented in QwtLegendItem. int QwtTextLabel::heightForWidth (intwidth) const [virtual] Returns the preferred height for this widget, given the width. Parameters: width Width int QwtTextLabel::indent () const Return label's text indent in pixels. int QwtTextLabel::margin () const Return label's text indent in pixels. QSize QwtTextLabel::minimumSizeHint () const [virtual] Return a minimum size hint. void QwtTextLabel::paintEvent (QPaintEvent *event) [protected, virtual] Qt paint event Parameters: event Paint event Reimplemented in QwtLegendItem. void QwtTextLabel::setIndent (intindent) Set label's text indent in pixels Parameters: indent Indentation in pixels void QwtTextLabel::setMargin (intmargin) Set label's margin in pixels Parameters: margin Margin in pixels void QwtTextLabel::setText (const QwtText &text) [virtual, slot] Change the label's text Parameters: text New text Reimplemented in QwtLegendItem. void QwtTextLabel::setText (const QString &text, QwtText::TextFormattextFormat = QwtText::AutoText) [slot] Change the label's text, keeping all other QwtText attributes Parameters: text New text textFormat Format of text See also: QwtText QSize QwtTextLabel::sizeHint () const [virtual] Return label's margin in pixels. Reimplemented in QwtLegendItem. const QwtText & QwtTextLabel::text () const Return the text. QRect QwtTextLabel::textRect () const Calculate the rect for the text in widget coordinates Returns: Text rect Author Generated automatically by Doxygen for Qwt User's Guide from the source code. Version 5.2.2 Mon Aug 1 2011 QwtTextLabel(3)
All times are GMT -4. The time now is 06:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy