Test Hexadecimal number


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Test Hexadecimal number
# 1  
Old 09-23-2009
Test Hexadecimal number

Hi,

I would like test if a number (with 2 digit, for example a9 , 0b ) is a hexadecimal number with 2 digit ?
# 2  
Old 09-23-2009
Quote:
Originally Posted by francis_tom
...
I would like test if a number (with 2 digit, for example a9 , 0b ) is a hexadecimal number with 2 digit ?
Maybe something like this ?

Code:
$
$ cat -n f1
     1  1234
     2  a9
     3  0b
     4  4AF980
     5  23xy9
     6  abcdef
     7  F9
     8  ffffff
     9  aaaaaa
    10  0
    11  -982f
    12  ff
    13  aa
    14  -1
    15  34
    16  -34
    17  a!b!c!
    18  9F
$
$ # pick two digit hexadecimal integers from f1
$ perl -lne 'chomp; print if (/^-*([0-9a-fA-F]+)$/ and length($1)==2)' f1
a9
0b
F9
ff
aa
34
-34
9F
$
$

tyler_durden
# 3  
Old 09-23-2009
thanks,

how i can do that with korn shell ?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

If statement test against number range [0-9]

Is it possible to test against a varible within a ranges in a if statement. ex. if ];then echo "not in range" else echo "number within range" fi (8 Replies)
Discussion started by: leemalloy
8 Replies

2. Shell Programming and Scripting

ksh script to test max number of parallel ssh connections

hello , I need to check how many parallel ssh connections my server can take the load of. I need to login to different host which i am planning to read from a file and then a write a loop which will do parallel ssh. Please provide suggestion on how i can write script for the same.\ Thank... (1 Reply)
Discussion started by: ABHIKORIA
1 Replies

3. Shell Programming and Scripting

Test of more than one number on the end of a string

Hi there, I have a bunch of interface names like e1000g0 nge1 dmfe3 I also have some that have longer (vlan tagged) names like e1000g123001 nge23003 e1000g999002 I need to determine whether the interface is one of the former or latter types and I would do that by seeing... (7 Replies)
Discussion started by: rethink
7 Replies

4. IP Networking

How to test max number of tcp connections

Hello, I wanna test max tcp connection value. Please suggest how to do that. Thanks. (2 Replies)
Discussion started by: gstoychev
2 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. 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

7. Shell Programming and Scripting

Test decimal number

Hi, I would like test if a number is a decimal number or not (9 Replies)
Discussion started by: francis_tom
9 Replies

8. Shell Programming and Scripting

need script to convert number in hexadecimal

hi , i need a script to convert number into hexadecimal base for example: 237=>ED it s very important for me thank you in advance for you help (5 Replies)
Discussion started by: mips
5 Replies

9. Shell Programming and Scripting

printing format for hexadecimal signed number

Hello Experts,, I m facing a problem as follows.. need help.. When I am giving the below command it gives me three digit hexadecimal number , for ex :- printf("%0.3x", 10); Output: 00a But I want the same for signed number also. Now when I am specifiying the... (10 Replies)
Discussion started by: user_prady
10 Replies

10. Shell Programming and Scripting

How can you Test for bad number

Anyone know the code to test for bad numbers? For example in ksh... Want the user to input an integer, but they input characters. read number while (number = letter) read number //until valid number is inputted thx for any help!! :confused: (3 Replies)
Discussion started by: gsxpower
3 Replies
Login or Register to Ask a Question