Operating System - HP-UX
1834164 Members
2978 Online
110064 Solutions
New Discussion

Shell program to choose from the o/p of ipcs -moba.

 
SOLVED
Go to solution
Anu Mathew
Valued Contributor

Shell program to choose from the o/p of ipcs -moba.

Hi people,

I was trying to write a script that will monitor the shared memory usage and will remove
entries with NATTCH=0. The following is the o/p of:

# ipcs -moba|sed '1-3d'|awk '{print $2 "\t" $9}'

0 2
1 0
3 1
4 0
205 3
206 1

The entries at the left are the IDs and that at the left are the NATTCH. I should be able to
pick the IDs with NATTCH=0 and do an ipcrm -m .

Thanks in advance for your time and patience.

Regards

Anu Mathew
1 REPLY 1
James R. Ferguson
Acclaimed Contributor
Solution

Re: Shell program to choose from the o/p of ipcs -moba.

Hi:

Here's one way:

IDS=`ipcs -moba|awk 'NR > 3 {if ($2==0) print $2}'`
for I in $IDS
do
ipcrm -m $I
done

...JRF...