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.
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
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.