- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Numeric validation
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-14-2002 02:35 PM
тАО02-14-2002 02:35 PM
TIA.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-14-2002 02:38 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-14-2002 06:21 PM
тАО02-14-2002 06:21 PM
Re: Numeric validation
Here is another method:
#/sbin/sh
expr `echo $1|awk -F\. '{print $1$2}'` + 0
if [ "$?" != 0 ]
then
echo is NOT a number
else
echo is a number
fi
Hope this helps. Regards.
Steven Sim Kok Leong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-14-2002 08:08 PM
тАО02-14-2002 08:08 PM
Re: Numeric validation
this one is faster since no additional processes are started:
case "$1" in
[0-9][0-9][0-9]) echo "3digit numeric" ;;
*) echo "NOT 3digit numeric" ;;
esac
HTH,
Wodisch
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-14-2002 08:14 PM
тАО02-14-2002 08:14 PM
Re: Numeric validation
I agree with Wodisch, if only plain 3-digit places are required. If you want to also take care of decimal places and negatives, JRF's script takes care of them and any number of digits. Mine too.
Hope this helps. Regards.
Steven Sim Kok Leong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-14-2002 11:42 PM
тАО02-14-2002 11:42 PM
Re: Numeric validation
there is a possibility which is even faster:
if (($1+1)) >/dev/null 2>&1
then
echo "$1 is a number!"
else
echo "$1 is something else
fi
Allways stay on the bright side of life!
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-15-2002 12:13 AM
тАО02-15-2002 12:13 AM
Re: Numeric validation
# a=123
# n=3
echo $a | grep -E "^[0-9]{$n}$"
123
# n=4
# echo $a | grep -E "^[0-9]{$n}$"
#
Rgds, Robin.