-   Programming (
-   -   sed help with variable (

RudraB 07-04-2008 12:01 AM

sed help with variable
i have a script:


for (( i=1;i<=9;i++ ))
j=`expr 10 - $i`
mkdirhier Dir/Mn${i}Cr${j}
cp FFILES/param.h Dir/Mn${i}Cr${j}
rho=`echo "scale=1; $i/10" | bc`
echo $rho
sed -e '6c\ parameter(nsite=369902,x=${i},y=1-x,nkp=17,maxrec=12)' Dir/Mn1Cr9/param.h>tmp$i
cp tmp$i Dir/Mn1Cr9/param.h
the problem is with sed line....i expect sed to replace x=${i}, where i is variable; but sed is just prompting ${i}; not the current value of $i:cry: ...any help?

Kenhelm 07-04-2008 01:10 AM

${i} needs to be out of the single quotes. Try something like this:-

so that ${i} is now in double quotes while the rest of the sed statement remains in single quotes.

All times are GMT -5. The time now is 04:21 AM.