- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- awk command not working in shell script
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
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
тАО12-05-2006 02:35 AM - last edited on тАО03-10-2013 07:38 PM by Cathy_xu
тАО12-05-2006 02:35 AM - last edited on тАО03-10-2013 07:38 PM by Cathy_xu
I am trying to grab output from awk utility in a script and email the output but script is failing. On HP 11 platform, I trying to get the fifth field from "bdf /var" output and send myself an email if /var is 90% or more full but I have not been able to get it right.
Output is needed for second line as first line has the header, not disk info. Here is what I wrote:
#!/bin/sh
bdf /var |sed 's/%//'|awk '{if ($5 >= 90) print $0;}'|mailx -s"`hostname` -File system full" MyId@email.com
exit
And bdf output is like this:
Server> bdf
Filesystem kbytes used avail %used Mounted on
/dev/vg00/lvol7 4194304 1756256 2422400 42% /var
P.S.This thread has been moved from HP-UX>General HP-UX > languages-HP Forums Moderator
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-05-2006 02:39 AM - last edited on тАО03-24-2017 01:17 AM by VidyaVI
тАО12-05-2006 02:39 AM - last edited on тАО03-24-2017 01:17 AM by VidyaVI
Re: awk command not working in shell script
Hi,
and welcome to the forums !
You may be interested in reading:
https://community.hpe.com/t5/forums/searchpage/tab/message?q=awk+command+
Please also read:
https://community.hpe.com/t5/Community-FAQ/FAQ-Kudos/td-p/6838486 on how to reward any useful answers given to your questions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-05-2006 02:42 AM
тАО12-05-2006 02:42 AM
Re: awk command not working in shell script
To skip the header line you could do:
# bdf /var |sed 's/%//'|awk '{if (NR>1 && $5 >= 90) print $0;}'
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-05-2006 02:43 AM
тАО12-05-2006 02:43 AM
Re: awk command not working in shell script
Here's an adaptation of a script I use to check/copy Oracle archivelogs:
#!/usr/bin/sh
typeset -i SIZE=$(bdf /var| awk '{getline; sub(/%/,""); print $5;}')
if [[ $SIZE -gt 90 ]]
then
mailx -m -s "[$(date +%m\/%d\/%y)] $(hostname) /var at 90+%!" your@email.addr
fi
exit 0
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-05-2006 02:46 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-05-2006 09:50 PM
тАО12-05-2006 09:50 PM
Re: awk command not working in shell script
# Show mount points over PCT
bdf|awk -v PCT=90 'NR==1||substr($5,1,index($5,"%")-1)+0>=PCT'
if you do not want header remove "NR==1||".
if you want different percentage to check chnage PCT=90 as you prefer.
HTH,
Art
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-05-2006 11:12 PM
тАО12-05-2006 11:12 PM