#!/bin/Bashwhoami=' WhoAmI 'if[$#-lt"1"] then echo'[program name] [Action Object]'Exit0fi# requires two parameters, parameter one: start line, parameter two: End line, parameter three: Operation Object function seddata{ forNumxinch' IPCS | Sed-n ${1},${2}p | Sed-n/${whoami}/p | Awk'{print $}'` DoIpcrm ${3} ${numx} done}function startp{ Case$1 inch "SHM") START= ' IPCs | Sed-n'/shmid/='' START= ' Expr $START +1' END= ' IPCs | Sed-n'/semaphore/='' END= ' Expr $END-2' #实际上, it's easier to match the empty line directly, for learning purposes #END="/^$/"Echo"start= $START; end= $END"seddata $START $END SHM; "sem") START= ' IPCs |sed-n'/semid/='' START= ' Expr $START +1' END= ' IPCs | Sed-n'/message/='' END= ' Expr $END-2' seddata $START $END sem;; "msq") START= ' IPCs | Sed-n'/msqid/='' START= ' Expr $START +1' END="/^$/"seddata $START $END msq; *) echo"the wrong argument! " ;; ESAC}if[" $"=" All"]then STARTP SHM startp sem start msqElseSTARTP $1Fiecho"Script Execution succeeded! "
Linux Shell Combat (IPCS tools)