0

Hi all,

I am trying to write a shell script that submit a couple of jobs .Then in the "job.e.." files looks for the "Finished with all tasks." string and if it exits it continues to lets say step 3 submitting job3 and if not to step 4 and submitting job4. Using commands "qsub job3" and "qsub sub4" respectively. Here is my first trial:

for ((  i = 1 ;  i <= 2;  i++  ))
do
find . -name "job_$i.e*" -exec grep "Finished with all tasks." '{}' \; -print
done

But the above command just prints weather the string exists or not and I don't know how I can proceed from here. I really appreciate any suggestion.

Edited by SakuraPink: n/a

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by cfajohnson
0


Do you know where the files, job_1.e and job_2.e, are? If so, why use find?

for file in job_*.e   ## adjust path if necessary
do
  if grep -q "Finished with all tasks." "$file"
  then
     : line found; do something
  else
     : line not found; do something else
  fi
done

Otherwise pipe the output of find to a script:

n=0
max=2

while [ $(( n += 1 )) -le $max ]
do
  find . -name "job_$i.e*" |
   while IFS= read -r file
   do
     if grep -q "Finished with all tasks." "$file"
     then
        : line found; do something
     else
        : line not found; do something else
     fi
   done
done
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.