#!/bin/bash
CONDOR_BIN=/usr/local/condor/bin
if( (test "$1" = "") || (test "$2" = "") )then
 echo "Syntax is $0 grep_string condor_command(s)"
 echo "meaning that condor_command (possibly with parameters) will be applied to all jobs matching grep_string"
 echo "e.g. this sets new priorities for baseFlag jobs: ./condor_grep baseFlag condor_prio -p 2" ;
else
 LIST=$($CONDOR_BIN/condor_q | grep $1 | egrep -o ^[0-9]*\.[0-9])
 if( test "$LIST" != "" )then
  for JOB in $LIST ; do
   echo "Executing $2 $3 $4 $5 $6 $7 $8 $9 $JOB"
   $2 $3 $4 $5 $6 $7 $8 $9 $JOB
  done ;
 fi ;
fi
