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 fredex@fcshome.stoneham.ma.us:
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 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.
Have you looked in the Advanced Bash Scripting guide? I dunno if it discusses that particular thing, but there is a lot of tricky stuff there that may help you.
-- ---- Fred Smith -- fredex@fcshome.stoneham.ma.us ----------------------------- "For the word of God is living and active. Sharper than any double-edged sword, it penetrates even to dividing soul and spirit, joints and marrow; it judges the thoughts and attitudes of the heart."
---------------------------- Hebrews 4:12 (niv) ------------------------------
users mailing list users@lists.fedoraproject.org To unsubscribe or change subscription options: https://admin.fedoraproject.org/mailman/listinfo/users Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines Have a question? Ask away: http://ask.fedoraproject.org