Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 07-04-2008, 12:01 AM   #1
Registered: Mar 2007
Distribution: Fedora
Posts: 264

Rep: Reputation: 23
Unhappy 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 ...any help?
Old 07-04-2008, 01:10 AM   #2
Registered: Mar 2008
Location: N. W. England
Distribution: Mandriva
Posts: 359

Rep: Reputation: 170Reputation: 170
${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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
sed, negate and variable muha Programming 2 04-16-2006 09:02 AM
Bash, using variable in sed fur Programming 3 11-12-2005 07:41 AM
insert output of sed into a variable hwouters Linux - General 3 11-06-2004 07:54 PM
sed and variable chirophil91 Programming 2 10-19-2004 03:23 AM
Expanding shell variable in sed goofyheadedpunk Programming 4 09-11-2004 05:17 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:05 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration