Sponsored Content
Top Forums UNIX for Advanced & Expert Users test the string is char or integer Post 302244654 by fpmurphy on Wednesday 8th of October 2008 10:50:23 AM
Old 10-08-2008
If you are using phksh, ksh88 or ksh93, here is an example of testing an input to determine if it is all numeric, letters or a mix of numbers and letters:
Code:
#!/bin/ksh

INPUT="ABC"

case $INPUT in
   ( +([0-9])       ) echo "$INPUT is all numbers" ;;
   ( +([a-zA-Z])    ) echo "$INPUT is all characters" ;;
   ( +([0-9a-zA-Z]) ) echo "$INPUT is alphanumeric" ;; 
   (               *) echo "$INPUT is something unknown" ;;
esac

exit 0

 

9 More Discussions You Might Find Interesting

1. Programming

Integer to String

Which function should I use to convert an Integer to a String or Char format ? Thanx (2 Replies)
Discussion started by: psilva
2 Replies

2. Programming

C function to test string or integer

Hi everyone , Is there any predefined C function that tests whether an input is string or an integer? Thank's in advance :) (3 Replies)
Discussion started by: qqq
3 Replies

3. Programming

to compare two integer values stored in char pointers

How can I compare two integer values which is stored in char pointers? suppose I have char *a and char *b having values 10 and 20. how can i find the shorter value? (1 Reply)
Discussion started by: naan
1 Replies

4. Shell Programming and Scripting

Test on string containing spacewhile test 1 -eq 1 do read a $a if test $a = quitC then break fi d

This is the code: while test 1 -eq 1 do read a $a if test $a = stop then break fi done I read a command on every loop an execute it. I check if the string equals the word stop to end the loop,but it say that I gave too many arguments to test. For example echo hello. Now the... (1 Reply)
Discussion started by: Max89
1 Replies

5. Shell Programming and Scripting

How to check weather a string is like test* or test* ot *test* in if condition

How to check weather a string is like test* or test* ot *test* in if condition (5 Replies)
Discussion started by: johnjerome
5 Replies

6. Programming

I don't know how to replace input char with appropriate integer

Hi guys, I asked for help on programming forums and no one didn't helped me so I ask for help here. I am playing with some tasks from my book and I can't figure where did I get wrong. From the first program I get a blank screen, program won't generate 10*10 matrix. And second problem is I... (6 Replies)
Discussion started by: solaris_user
6 Replies

7. Shell Programming and Scripting

how to compare string integer with an integer?

hi, how to I do this? i="4.000" if ; then echo "smaller" fi how do I convert the "4.000" to 4? Thanks! (4 Replies)
Discussion started by: h0ujun
4 Replies

8. Shell Programming and Scripting

How do I test the first char of each line in an array

Hi folks, I am self-learning as I can I have a script that has read a file into an array. I can read out each line in the array with the code: for INDEX in {0..$LENGTH} ## $LENGTH was determined at the read in do echo "${data}" done What I need to do is test the first char... (2 Replies)
Discussion started by: Marc G
2 Replies

9. Shell Programming and Scripting

Perl Script Integer Test

Working out a small problem, I have a need of a Perl snippet which might look something like this: use integer; ... if ($changingNumber / 2) { do something; } else { do something else; } ... What I want to happen is for "if" to resolve as "true" every time a whole... (3 Replies)
Discussion started by: LinQ
3 Replies
INPUT(5)							File Formats Manual							  INPUT(5)

NAME
input - input data file format DESCRIPTION
This manual page describes the output format of the file created by the Yagi-Uda project input or first programs. The file is an ASCII file, so can be edited manually if required. It is read by yagi or optimise. The program optimise also creates the same file format. NOTES FREQUENCY MIN_FREQUENCY MAX_FREQUENCY STEP_FREQUENCY ELEMENTS DRIVEN PARASITIC ANGULAR_STEP DATA_DRIVEN DATA_PARASITIC The # is used as a comment. A typical file, for an antenna designed for the 2m amateur band (144-146 MHz) might be as shown below. Note: 1) Reflector is at position 0.0 2) All elements lengths/positions are in m. NOTES This line can be up to 400 characters. FREQUENCY 145.000000 MIN_FREQUENCY 144.000000 MAX_FREQUENCY 146.000000 STEP_FREQUENCY 0.100000 ELEMENTS 10 DRIVEN 1 PARASITIC 9 ANGULAR_STEP 180.000000 #DATA_DRIVEN x y length diameter voltage phase DATA_DRIVEN 0.30993 0.000000 1.002492 0.0063000000000000 1.000000 0.000000 # DATA_PARASITIC x y length diameter DATA_PARASITIC 0.00000 0.00000 1.01902 0.00630 0.49859 0.00000 0.95551 0.00630 1.07338 0.00000 0.93595 0.00630 1.81020 0.00000 0.92050 0.00630 2.58152 0.00000 0.91322 0.00630 3.30390 0.00000 0.91243 0.00630 4.03692 0.00000 0.90423 0.00630 4.64108 0.00000 0.89081 0.00630 5.37418 0.00000 0.83912 0.00630 FILES
filename ASCII description of antenna. filename.out binary file SEE ALSO
yagi(1), output(1), input(1), optimise(1), first(1) and yagi(5). AUTHORS
Dr. David Kirkby G8WRB (david.kirkby@onetel.net), with help with converting to DOS from Dr. Joe Mack NA3T (mack@fcrfv2.ncifcrf.gov). Yagi version 1.16 24th October 2000 INPUT(5)
All times are GMT -4. The time now is 04:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy