日期:2014-05-16 浏览次数:20935 次
[User:root Time:20:23:11 Path:/home/liangdong/shell]$ cat test.sh
#!/bin/sh
function ipc_remove() {
row=0;
ipcs -$1 | grep -v ^$ | while read line; do
if [ "$row" -ge "2" ];then
echo $line;
shmid=`echo $line | awk '{print $2}'`;
if [ "$shmid" -ne "0" ];then
ipcrm -$1 $shmid
fi
fi
let row=$row+1
done
}
ipc_remove "m";
ipc_remove "s";
ipc_remove "q";
------解决方案--------------------
试试
ipcs -m | awk '$1~/0x/ {print "ipcrm -M", $1}' | sh