- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: awk Help
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
Forums
Discussions
Discussions
Discussions
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
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
11-30-2004 12:09 AM
11-30-2004 12:09 AM
I want to test a command to see if the percentage is less than or greate than. It seems the % sign is giving me an error. Is there a way to test percentage rather than just a number?
if [[ $(swapinfo -tm | grep -i localfs | awk '{ print $5 }') -lt 80% ]]; then
echo " Filesystem Swap Is Cool "
exit
fi
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2004 12:17 AM
11-30-2004 12:17 AM
Re: awk Help
How about adding a sed step to remove the percent sign?
swapinfo -tm | grep -i memory | awk '{ print $5 }' |sed 's/%//'
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2004 12:19 AM
11-30-2004 12:19 AM
Re: awk Help
Thanks anyway.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2004 12:29 AM
11-30-2004 12:29 AM
Re: awk Help
you can perhaps add a second |
something like
| awk '{ print $5 }') |tr -d % -lt 80
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2004 12:31 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2004 12:32 AM
11-30-2004 12:32 AM
Re: awk Help
Thanks Leif
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2004 12:35 AM
11-30-2004 12:35 AM
Re: awk Help
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2004 12:49 AM
11-30-2004 12:49 AM
Re: awk Help
Other than the fact it was my mistake, I hate sed. I dont know why, but I do.
Right, no difference, still not evaluating true percentage value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2004 01:03 AM
12-01-2004 01:03 AM
Re: awk Help
I do it like this:
ping fradban -n 5 | grep 'packet loss' | awk '{print $7}' | sed 's/\%//g'
The result is the numerical part of the percentage dropped.
I store that in a variable called drp.
Then I test that:
if [ "$drp" = "" ]
then
drp = "99999"
fi
if [ "$drp" -gt "10" ]
then
# page someone on IT staff
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2004 02:31 AM
12-01-2004 02:31 AM
Re: awk Help
num=$(swapinfo -tm | awk '/localfs/ {sub("%","",$5);print $5;}')
if (( $num < 80 )) ;then
...