Hello:
I wasn't sure if this was better off here or in the basics forum, seeing as it is one of my first scripts, but I was afraid someone would say it didn't belong in that forum. To make a long story short, I have a series of text files that contain commercial medicine names along with the amount used by month, and these I need to make into generic names. After mucking about some, I made a script to pair the name with a generic name and substitute it, using awk and sed, and all was well. Later, I tried to remove the absolute paths to the involved files from the script (so I could use the same script for files in different directories), and it stopped working, and hasn't worked even after I replaced the paths. The shell returns the following error:
Quote:
./gen.sh: line 33: syntax error near unexpected token `done'
./gen.sh: line 33: `done'
. The script is as follows:
Code:
#!/bin/bash
#script to change from commercial to generic names
outer=1
num=107
total=`wc -w lista.txt | awk '{ print $1 }'`
while [ $outer -lt 10 ]
do
inner=1
while [ $inner -lt $((total)) ]
do
brand=`cat lista.txt | awk '{ print $'$inner' }'`
gen=`cat lista.txt | awk '{ print $'$((inner+1))' }'`
sed -i --line-length=0 s/$brand/$gen/g /home/yon/Residencia/tesis/2007/rfaran10_int_0$num.txt
inner=$((inner+2))
done
outer=$((outer+1))
num=$((num+100))
done
num=1007
total=`wc -w lista.txt | awk '{ print $1 }'`
while [ $outer -lt 13 ];
do
inner=1
while [ $inner -lt $((total)) ]
do
brand=`cat lista.txt | awk '{ print $'$inner' }'`
gen=`cat lista.txt | awk '{ print $'$((inner+1))' }'`
sed -i --line-length=0 s/$brand/$gen/g /home/yon/Residencia/tesis/2007/rfaran10_int_$num.txt
inner=$((inner+2))
done
outer=$((outer+1))
num=$((num+100))
done
Could anyone help me figure out what is wrong? The do's and done's seem paired alright, and I can't see what I'm missing
Yonatan