![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Type I and Type II Errors - The Heart of Event Processing | iBot | Complex Event Processing RSS News | 0 | 12-05-2007 03:50 PM |
| array type has incomplete element type | jaganadh | High Level Programming | 1 | 07-24-2007 12:54 AM |
| String type to date type | rinku | Shell Programming and Scripting | 1 | 05-30-2007 03:56 AM |
| Human readable type vs MIME type detection using file | spauldingsmails | Shell Programming and Scripting | 0 | 03-21-2007 09:43 PM |
| find . -type d -exec cd {} \; | shimont | UNIX for Dummies Questions & Answers | 2 | 11-23-2005 08:42 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
ksh : find value type
Hi,
Simple question : How to find the value type from a variable : Ex : var="1" => type is numeric var="a" => type is character Thx |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Have a look at this
Code:
$ cat mad.ksh #! /bin/ksh [[ -z "$1" ]] && echo "I cant work without an input" && exit 1 INPUT="$@" [[ "$INPUT" == ?(+|-)+([0-9]) ]] && echo "$INPUT is numeric" && exit 0 [[ "$INPUT" == +([a-zA-Z]) ]] && echo "$INPUT is character" && exit 0 [[ "$INPUT" == *([0-9]|[a-zA-Z])* ]] && echo "$INPUT is alpha-numeric" && exit 0 Code:
$ ./mad.ksh 123 123 is numeric $ ./mad.ksh abc abc is character $ ./mad.ksh abc123 abc123 is alpha-numeric -vino Last edited by vino; 09-21-2005 at 03:30 AM. Reason: Enhanced to check for +ve and -ve numbers. |
|
#3
|
|||
|
|||
|
Hi vino
Funny code Thx for it, I'll find some ideas for my problem. Rgds |
|||
| Google The UNIX and Linux Forums |