Solved

using sed and variables in bash

Posted on 2013-06-07
3
465 Views
Last Modified: 2013-06-08
greetings, I have these commands:

base=/u01/Integrity/PMDR/OGL

sed -e '/<ManufacturedProduct>/r /u01/Integrity/PMDR/OGL/Stage/images.xml' ${base}/Stage/SPL.xml > ${base}/Stage/SPLout.xml

where it says: /u01/Integrity/PMDR/OGL/Stage/images.xml
but I want it parameterized like this: ${base}/Stage/images.xml

right now this does not work:
sed -e '/<ManufacturedProduct>/r ${base}/Stage/images.xml' ${base}/Stage/SPL.xml > ${base}/Stage/SPLout.xml

what can I do to get ${base} to be recognized?
thanks.
0
Comment
Question by:Evan Cutler
3 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
Comment Utility
Use double quotes " instead of the single quotes '

sed -e "/<ManufacturedProduct>/r ${base}/Stage/images.xml" ${base}/Stage/SPL.xml > ${base}/Stage/SPLout.xml
0
 
LVL 11

Expert Comment

by:tel2
Comment Utility
Hi arcee123,

I agree with wmp's comment about quotes.  Double quotes allow for interpolation, which is what you need here.

The '-e' switch is not required here.  Retaining it won't cause a problem, though.
0
 
LVL 9

Author Closing Comment

by:Evan Cutler
Comment Utility
Thanks boss.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now