Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a better way do this?

Status
Not open for further replies.

vuakhobo

Technical User
Apr 22, 2004
41
0
0
US
I have a job_list.dat contains say 5 jobs (a b c d e)
if job b failed at first run
I want to produce a re_run.dat only contains 4 jobs (b c d e)
I have written a code below. Can some one show me to do the same thing in awk ?

Here is my code


set -A list $(cat $job_list)
a=0
while [ "$a" -lt ${#list[*]} ]
do
if [ "${list[$a]}" == "$fail_at" ];then
begin=$a
break
fi
(( a+=1 ))
done
echo "match:$begin"
while [ "$begin" -lt ${#list[*]} ]
do
echo ${list[$begin]} > $re_run
(( begin+=1 ))
done
 
You haven't choosen a useful title. How should your posting be found?

Do you search for a better solution, or an AWK-solution, and why awk?

You want to rerun b if b failed? If a failed!

And please use code-tags.

Code:
set -A list $(cat $job_list)
a=0
while [ "$a" -lt ${#list[*]} ]
do
     if [ "${list[$a]}" == "$fail_at" ];then
        begin=$a
        break
     fi
     (( a+=1 ))
done
echo "match:$begin"
while [ "$begin" -lt ${#list[*]} ]
do
    echo ${list[$begin]} > $re_run
    (( begin+=1 ))
done

don't visit my homepage:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top