Re: checking for hexadecimal vals only in a string in bash

2014-09-19 Thread inode0
On Thu, Sep 18, 2014 at 4:31 PM, Chris Kottaridis 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 [[ $va

Re: checking for hexadecimal vals only in a string in bash

2014-09-18 Thread Patrick O'Callaghan
On Thu, 2014-09-18 at 16:31 -0500, Chris Kottaridis wrote: > if [[ $val =~ '/^[A-Fa-f0-9]+$/' ]] ; then > echo is hex > else > echo is not hex > fi You don't need the / or ' Also, this isn't searching for any hex string, it's searching for lines consisting only of a single hex string. po

Re: checking for hexadecimal vals only in a string in bash

2014-09-18 Thread Dennis Kaptain
try this: if [[ $VAL2 =~ ^[A-Fa-f0-9]*$ ]] ; then echo is hex else echo is not hex fi 2014-09-18 17:34 GMT-05:00 Fred Smith : > On Thu, Sep 18, 2014 at 04:31:03PM -0500, Chris Kottaridis wrote: >> In a bash shell script I want to see if a string has nothing but >> hexadecimal values in

Re: checking for hexadecimal vals only in a string in bash

2014-09-18 Thread Fred Smith
On Thu, Sep 18, 2014 at 04:31:03PM -0500, Chris Kottaridis 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 wit

checking for hexadecimal vals only in a string in bash

2014-09-18 Thread Chris Kottaridis
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 tr