- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- using for loop
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
01-21-2006 10:01 PM
01-21-2006 10:01 PM
what i did is
1- ioscan -funCdisk >>f1
2- cat f1|grep rdsk|awk{'print$2'}>f2
3- for i in 'cat f2'
do
diskinfo $i>>f3
done
4- cat f3|grep size>>f4
5-cat size.out|awk{'print $2'}>f5
6- f5 output , it contains only numbers , i want to use script to calculate the sum of these number ??
waiting for reply
thanx
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2006 12:10 AM
01-22-2006 12:10 AM
SolutionTOTAL=0
for i in `ioscan -funCdisk | grep rdsk | awk ' { print $2 } '`
do
NUMBER=`diskinfo $i | grep size | awk ' { print $2 } '`
# that gives you the size of one disk, now add it to the running total
eval TOTAL=($TOTAL+$NUMBER)
done
echo $TOTAL
Just check my syntax on the eval statement, I always get that wrong.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2006 02:04 AM
01-22-2006 02:04 AM
Re: using for loop
to sum up:
# awk '{s += $1}END {print s}' < f5
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2006 03:36 AM
01-22-2006 03:36 AM
Re: using for loop
Beware that a simple summation of the values returned by 'diskinfo' by walking the output of 'ioscan', is going to count alternate links (pvlinks) more than once, inflating the amount of disk you think you have.
Also, if you fail to skip unmounted CD|DVDROM devices, the 'diskinfo' query will hang.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2006 12:14 AM
01-23-2006 12:14 AM
Re: using for loop
#!/usr/bin/ksh
TOTAL=0
ioscan -funCdisk 2/dev/null |\
grep rdsk|\
awk '{print $NF}'\
>ioscan.txt
while read -u3 i; do
SIZE=$(diskinfo $i|\
grep size|\
awk '{ print $2}'\
)
(( TOTAL = TOTAL + SIZE ))
done 3
rm -f ioscan.txt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2006 12:26 AM
01-23-2006 12:26 AM
Re: using for loop
do
diskinfo $i|grep -E "describe|size" >> outputfile
done
will do the first part for you.
Mark Syder (like the drink but spelt different)