- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- script query
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
тАО08-20-2009 07:18 AM
тАО08-20-2009 07:18 AM
I require ur help finih below small script.
Actually its in solaris
1. for i in `df -h |awk '{print $1}'|grep -i /dev` -- it will give below output
/dev/dsk/c0t0d0s3
/dev/dsk/c0t1d0s4
/dev/dsk/c0t0d0s6
my query is.. A=`df -h $i |awk '{print $5}'`
output is
capacity
78%
I dont want 'capacity' to display.How to remove that heading..
Plz help on this
regards
himacs
Solved! Go to Solution.
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-20-2009 07:23 AM
тАО08-20-2009 07:23 AM
Re: script query
# A=$(df -h $i | awk 'NR>1 {print $5}')
...will skip the first line of the input.
Notice that instead of using backticks, I have used the Posix '$( ... )' syntax. It is clearer.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-20-2009 07:38 AM
тАО08-20-2009 07:38 AM
Re: script query
Below is my script
$ vi test
"test" 18 lines, 245 characters
for i in `df -h|awk '{print $1}'|grep -i /dev`
A=`(df -h $i |awk 'NR>1 {print $5}')`
B=`(df -h $i |awk 'NR>1 {print $6}')`
if [$A -gt 50]
then
echo " FS usage of $B is $A%"
fi
error is - ./test: syntax error at line 7: `A=`(df -h $i |awk 'NR>1 {print $5}')`' unexpected
i tried with $ with A line but error..
any body tells whats the wrong..
Actually i want to display the mountpoint which usage are more than 50..
regards
himacs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-20-2009 08:01 AM
тАО08-20-2009 08:01 AM
Re: script query
HP-UX doesn't have the '-h' switch to 'df'. If you use 'bdf' you could do:
# cat ./myscript
#!/usr/bin/sh
bdf | awk 'NR>1' | while read X X X X A B
do
A=$(echo ${A} | sed -e 's/%//')
if [ $A -gt 50 ]; then
echo "FS usage of $B is $A%"
fi
done
...
Notice that whitespace surrounds the test (in square brackets). You repetively used an 'awk' to snip what you already had. Here, it's simpler to the shell do the read and split the line into fields. We need to snip the "%" character and we do that with a simple 'sed'.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-20-2009 08:07 AM
тАО08-20-2009 08:07 AM
Re: script query
Thanx for the reply..
Actually this is for sun server..
I thought shell scripting is same for both the versions
regards
himacs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-20-2009 08:19 AM
тАО08-20-2009 08:19 AM
Re: script query
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-20-2009 08:24 AM
тАО08-20-2009 08:24 AM
Solution> Actually this is for sun server..
I thought shell scripting is same for both the versions
UNIX versions are variations of the AT&T System V and the Berkley BSD lines and differ in some of the commands they offer to accomplish the same task.
http://en.wikipedia.org/wiki/UNIX_System_V
http://en.wikipedia.org/wiki/BSD_UNIX
You should easily be able to modify my last script offering to accomodate your needs. UNIX and Linux variations might have minor differences but fundamentally they are all very similar.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-20-2009 01:41 PM
тАО08-20-2009 01:41 PM
Re: script query
Solaris
df -k | grep -v capacity | awk '($5>50) {print "FS usage of "$6" is "$5}'
HP-UX
bdf | awk '($5>50) {print "FS usage of "$6" is "$5}'
Buena suerte
JEA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-20-2009 10:04 PM
тАО08-20-2009 10:04 PM
Re: script query
Thanx
Above command is given the below output
bash-3.00$ df -k | grep -v capacity | awk '($5>75) {print "FS usage of "$6" is "$5}'
FS usage of / is 75%
FS usage of /platform/sun4v/lib/libc_psr.so.1 is 75%
FS usage of /platform/sun4v/lib/sparcv9/libc_psr.so.1 is 75%
FS usage of /reuters is 89%
is it possible to avoid " /platform", I want to grep only "/dev" filesystems.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-21-2009 07:15 AM
тАО08-21-2009 07:15 AM
Re: script query
Try this on Solaris:
# df -k | awk '! /capacity/ && ($5>75) && /\/dev/ {print "FS usage of "$6" is "$5}'
note the multiple conditions at the beginning of awk, this way you won't have to use grep and so it is more powerful.
Unix operates with beer.