打印

两个小脚本一个用于去注释一个用于列出或杀死匹配的程序

作者 supersun. Posted in Linux

列出或杀死匹配的程序
#!/bin/sh
#name:lkp
#comment:list or kill processor
if [ $# = "2" ] && [ $2 = "l" -o $2 = "k" ] ; then
{
        if [ -z "$2" -o "$2" = "l" ]; then
                ps aux |grep "$1" |grep -v "grep"|grep -v "/bin/sh"|awk '{print "\t" $1"\t"$2"\t"$11}'
        elif [ "$2" = "k" ]; then
                ps aux |grep "$1" |grep -v "grep"|grep -v "/bin/sh"|awk '{print $2}'|xargs kill
        else
                echo "Useage:$0 processname l|k";
        fi
}
else
{
        echo "usage:
                list the match processor: `basename $0` processor2match l
                kill the match processor: `basename $0` processor2match k"
}
fi

去掉注释:
#!/bin/sh
#name:clcom
#clear the comment
grep -v -e "^#" -e "^  *#" -e "^$" $1


    发布评论...