On Thu, Sep 18, 2014 at 4:31 PM, Chris Kottaridis chriskot@quietwind.net wrote:
In a bash shell script I want to see if a string has nothing but hexadecimal values in it.
So:
A098FE or af098fe
should be true
hello
should not.
How do I check for that ?
I've been playing with
if [[ $val =~ '/^[A-Fa-f0-9]+$/' ]] ; then echo is hex else echo is not hex fi
I've tried various incantations of above and also tried using grep but can't seem to get it just right.
Any help appreciated.
Chris,
Looks like you are really close.
if [[ $val =~ ^[A-Fa-f0-9]+$ ]] ; then
John