How can I delete all not used semaphores and shared memory with a single command on a UNIX-like system, e.g., Ubuntu?
1 line will do all
For message queue
ipcs -q | sed "$ d; 1,2d" | awk '{ print "Removing " $2; system("ipcrm -q " $2) }'
ipcs -q will give the records of message queues
sed "$ d; 1,2d " will remove last blank line ("$ d") and first two header lines ("1,2d")
awk will do the rest i.e. printing and removing using command "ipcrm -q" w.r.t. the value of column 2 (coz $2)