#!/bin/bash USER=$1 PROCS="rtorrent deluged utorrent.exe" NMAX=1 PROCLIST=`ps -u $USER` COUNT=0 for proc in $PROCS; do NGREP=`echo "$PROCLIST" | grep -c $proc` COUNT=`expr $COUNT + $NGREP` done if [ $COUNT -gt $NMAX ]; then for proc in $PROCS; do echo "$PROCLIST" | grep $proc | cut -c 1-5 | xargs kill done fi