Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
Operating System - Tru64 Unix
cancel
Showing results for 
Search instead for 
Did you mean: 

awk command and grep command

zhqiang
Occasional Advisor

awk command and grep command

when I used the command of '> vmstat -P'
I got the result of '

> vmstat -P

Total Physical Memory = 4096.00 M
= 524288 pages

Physical Memory Clusters:

start_pfn end_pfn type size_pages / size_bytes
0 885 pal 885 / 6.91M
885 524279 os 523394 / 4089.02M
524279 524288 pal 9 / 72.00k

Physical Memory Use:

start_pfn end_pfn type size_pages / size_bytes
885 1033 scavenge 148 / 1.16M
1033 2191 text 1158 / 9.05M
2191 2452 data 261 / 2.04M
2452 2933 bss 481 / 3.76M
2933 3224 kdebug 291 / 2.27M
3224 3231 cfgmgmt 7 / 56.00k
3231 3233 locks 2 / 16.00k
3233 3249 pmap 16 / 128.00k
3249 4001 unixtable 752 / 5.88M
4001 4049 logs 48 / 384.00k
4049 16216 vmtables 12167 / 95.05M
16216 524279 managed 508063 / 3969.24M
============================
Total Physical Memory Use: 523394 / 4089.02M

Managed Pages Break Down:

free pages = 167589
active pages = 151813
inactive pages = 18504
wired pages = 57504
ubc pages = 112801
==================
Total = 508211

WIRED Pages Break Down:

vm wired pages = 11887
ubc wired pages = 0
meta data pages = 5210
malloc pages = 25153
contig pages = 3738
user ptepages = 10697
kernel ptepages = 453
free ptepages = 9
==================
Total = 57147
'
but,How can i get the number of '4096.00'?


5 REPLIES
Venkatesh BL
Honored Contributor

Re: awk command and grep command

The following seem to work for me now:
# vmstat -P |grep "Total Physical Memory" |head -1|awk '{print $5}'

Not sure if it will work for all cases.
zhqiang
Occasional Advisor

Re: awk command and grep command

I want to get the result of '524288 ',but the command of
" vmstat -P |grep "=" |head -2|awk '{print $2}' " returns the result of
"
Physical
524288 "
"Physical" is not what i want,what is wrong?
Dennis Handly
Acclaimed Contributor

Re: awk command and grep command

>Venkatesh: vmstat -P |grep "Total Physical Memory" |head -1|awk '{print $5}'

You could eliminate the grep and head:
vmstat -P | awk '/Total Physical Memory/ {print $5; exit}'
Venkatesh BL
Honored Contributor

Re: awk command and grep command

> vmstat -P |grep "=" |head -2|awk '{print $2}

You got different result because, you typed a different grep pattern!

Moreover, you could use the command provided by Dennis now.
zhqiang
Occasional Advisor

Re: awk command and grep command

I see , I can use the command of "vmstat -P |grep "=" |awk 'NR==2 {print $2} " to get the result in the second line.
Thanks.