sed conditional string replace for each line

Hi all,
I appreciate the enormous amount of knowledge that flows in this forum.
I am an average UNIX user. I have many files with lines like the below. I have separated each line with space for ease of reading. I need to replace the first occurance of "/00" with null on those lines that have find_corp_pdm_part. I know s/search/replace/n replaces the nth occurance but I would be happy to know if I can check the condition of "find_corp_pdm_part" on the replacing line. Thanks all guys, you are all doing wonderful job.

2.<A HREF="/cgi-bin/perseus/find\_pdm_part.cgi/5187-1238/54">5187-1238</A>                CARD-PEN-INFO                      1.0000   54              <

A HREF="/cgi-bin/perseus/bom/find_parents_in_html/5187-1238/54">Parents</A>

2.&lt;A HREF="/cgi-bin/perseus/find\_corp\_pdm_part/7121-7243/00"&gt;7121-7243&lt;/A&gt;                LABEL-BLANK 3-IN-WD 3-IN-LG PP     1.0000   00

<A HREF="/cgi-bin/perseus/bom/find_parents_in_html/7121-7243/00">Parents</A>

2.&lt;A HREF="/cgi-bin/perseus/find\_corp\_pdm_part/8120-6260/00"&gt;8120-6260&lt;/A&gt;                Power cord \(N.A.  LAR  AP\)         1.0000   00

BTW, I have tried shell script ans loops to read line by line but that hurts by destroying the existing format (tabs replaced with one white space), please help

for FILE in $FILES
do
{
while read LINE
do
echo $LINE | grep "find_corp_pdm_part"
if [ $? -eq 0 ]
then
echo $LINE | sed 's#/00">#">#' >> temp
else
# [ "$LINE" = "" ] && { echo "" >> $FILE.new$$ ; continue ; }
echo $LINE >> temp
fi
# set -- $LINE
done
} < $FILE
mv temp $FILE
done

Try this sed command :

sed '/find_corp_pdm_part/s_/00__' inputfile

Modify your while loop (this will preserve spaces and tabs) :

while IFS= read LINE

Jean-Pierre.

Perl is a good (direct) option:

perl -pi -e "s/\/00//&&/find_corp_pdm_part/" file/s 

The sed and the perl solution won't work if you have double zero's after the 4th slash.

Try this:

awk 'BEGIN{OFS=FS="/"}$4=="find_corp_pdm_part"{sub("^00","",$6)}1' file

Regards

Just add the quote in the pattern:

perl -pi -e "s/\/00\"//&&/find_corp_pdm_part/" file/s

Regds

Like I said before, you people are great.

I got away with my problem by using the very first solution by Aigles. I believe all the other suggestions work too. I never posted queries in forum but the very first one was overwhelming. I promise to use it judiciously and also try to help others to the best of my knowledge. This thread is closed unless there is really anything fascinating.

Thanks guys, keep up the good work!!!