LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices



Reply
 
Search this Thread
Old 07-04-2008, 01:01 AM   #1
RudraB
Member
 
Registered: Mar 2007
Distribution: Fedora
Posts: 262

Rep: Reputation: 23
Unhappy sed help with variable


i have a script:

Quote:
for (( i=1;i<=9;i++ ))
do
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
done
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, 02:10 AM   #2
Kenhelm
Member
 
Registered: Mar 2008
Location: N. W. England
Distribution: Mandriva
Posts: 333

Rep: Reputation: 141Reputation: 141
${i} needs to be out of the single quotes. Try something like this:-
Code:
'........before......'"${i}"'.....after.....'
so that ${i} is now in double quotes while the rest of the sed statement remains in single quotes.
 
  


Reply


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 10:02 AM
Bash, using variable in sed fur Programming 3 11-12-2005 08:41 AM
insert output of sed into a variable hwouters Linux - General 3 11-06-2004 08:54 PM
sed and variable chirophil91 Programming 2 10-19-2004 04:23 AM
Expanding shell variable in sed goofyheadedpunk Programming 4 09-11-2004 06:17 PM


All times are GMT -5. The time now is 01:07 AM.

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