- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Numeric comparaison with ksh
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
тАО10-25-2008 12:11 PM
тАО10-25-2008 12:11 PM
I've a script with something like this :
SA=$(df -m -P | grep -i /logs | awk '{print $4}')
if [[ $SA < 900.25 ]] ;then
...
Here, is it a numeric compare or a string compare ?
Bests regards
Den
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-25-2008 12:44 PM
тАО10-25-2008 12:44 PM
Re: Numeric comparaison with ksh
if [[ $SA -le 900.25 ]] ;then
correct in any situation?
Regards
Den
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-25-2008 12:49 PM
тАО10-25-2008 12:49 PM
Re: Numeric comparaison with ksh
;-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-25-2008 01:51 PM
тАО10-25-2008 01:51 PM
Solutionhttp://www.docs.hp.com/en/B2355-60130/ksh.1.html
For shells, the mathmatical symbol operators compare *strings* and the English-like ones (-lt, -gt, -le, -ge, -eq -ne) perform *numeric* comparisons.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-25-2008 02:57 PM
тАО10-25-2008 02:57 PM
Re: Numeric comparaison with ksh
Hmm, what version of Unix is that ?!
HP-UX 11.31 does not have a -m option for df, only -k.
Why not have awk do the grepping and the comparing?
A shell is not going to do the decimal fractions.
Awk is happy to.
What will your scipt do when someone mounts /logs_backup or some such?
SA=$(df -m -P | awk -i '/\/logs$/{print int ($4 - 900.25) }')
Note: hpux does not have a -i with the standard awk. gawk has that. either speel out the mount point in proper casing or activate IGNORECASE or lowercase() the column.
fwiw,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2008 04:09 AM
тАО10-26-2008 04:09 AM
Re: Numeric comparaison with ksh
As mentioned, this is a string compare unless you have it within arithmetic expressions, (( )) or use awk(1). And even there it will fail since ksh and sh don't do floating point. You need ksh93:
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1151323
>Hein: activate IGNORECASE or lowercase() the column.
HP-UX's awk doesn't have IGNORECASE or lowercase() but has tolower().
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-17-2008 01:31 PM
тАО12-17-2008 01:31 PM