The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 11-18-2007
DKNUCKLES DKNUCKLES is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 12
egrep syntax question

I have a (seemingly) simple question for you guys

I need my script to allow users to enter numbers with either 2 decimal points or with no decimal points.

here's the code I have right now for testing, but I can't for the life of me figure out whats wrong!

(it's been broken up into 2 different grep statements)

decimal=10.500
echo $decimal | egrep -q '[0-9+]' && echo success || echo failure
echo $decimal | egrep -q '[0-9+]\.[0-9][0-9]' && echo success || echo failure

any insight would be greatly appreciated as this has been the cause of much frustration for me!