![]() |
|
|
|||||||
| Home | Forums | Register | Rules & FAQ | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
Other UNIX.COM Threads You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| variables in shell | viko | Shell Programming and Scripting | 2 | 03-03-2008 07:09 PM |
| Double Substitution variables in ksh | xiamin | Shell Programming and Scripting | 19 | 05-23-2007 01:35 AM |
| Using shell variables In awk | nortypig | Shell Programming and Scripting | 11 | 08-23-2006 09:48 PM |
| Newlines in shell variables | narcvs | Shell Programming and Scripting | 4 | 03-15-2006 01:58 PM |
| substituting shell variables | suds19 | Shell Programming and Scripting | 1 | 10-16-2002 05:55 AM |
![]() |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
shell variables and sed substitution
My specific goal: automatically edit a Makefile variable's (EXTRAVERSION)
value in a kernel Makefile. So, I have a shell script that takes one parameter, a version string: buildkernel.sh 2.6.18.21.7-custom In the script, I assign the parameter to K_VER: K_VER="2.6.18.21.7-custom" I perform string operations until I get this: XTRA_K_VER=".21.7-custom" I export it (thinking that the proper value would be substitued when make was run, but the variable is not expanded): export XTRA_K_VER So, maybe I should forget the export? I am using the variable, XTRA_K_VER, in a substitution in a Makefile with the idea that the variable would be expanded: sed -f script.sed <Makefile.old >Makefile.new where script.sed contains the following: s#\([[:blank:]]*EXTRAVERSION\)[[:blank:]]*=[[:blank:]]*.*#\1 = $XTRA_K_VER# The issue I am experiencing is that I want the value of XTRA_K_VER to be used in the Makefile as opposed to the literal variable name. I do not have a preference whether I insert the variable form of the entity (into the Makefile) or the literal string value of the variable. From what I have described, is there a reasonably clean way to let the sed script expand the value of the variable before the substitution? I thought about re-writing the sed script dynamically upon every invocation of the program, but that seems a bit extreme to me (and potentially challenging for others to maintain in the future). Thanks in advance. I really appreciate the experience of the people on this site. ![]() Cheers, :-D |
| Forum Sponsor | ||
|
|
|
|||
|
That's right. Also just for the record, the "export" doesn't add anything; the variable is interpolated by Make itself before the command executes. (Export is for putting stuff in the environment, so you can e.g. modify the PATH of all the processes you run from your Makefile.)
|
|||
| Google UNIX.COM |