LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 04-09-2005, 05:13 AM   #1
Miro1
LQ Newbie
 
Registered: Apr 2005
Posts: 6

Rep: Reputation: 0
Sed problem


In my hand made makefile, I am trying to find/update config.h source to save $prefix value into the line like '#define INSTALL_PREFIX "$prefix" ' (replace $prefix with actual value here)

My makefile looks like this:

prefix=/usr

all: updatesrc

updatesrc:
sed -i 's_\#define INSTALL_PREFIX .*_\#define INSTALL_PREFIX "$(prefix)"\r_' ./config.h


Problem is this sed line reports errors, probably due to $prefix value having slash characters inside.

How can I fix this ? Any ideas?

TIA,
Miro
 
Old 04-09-2005, 06:06 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You can use a different character other than a slash as a seperator. The octothorpe character is often used, however that would conflict with the ones used for '#define'. Whatever character you use for a seperator, if the same character appears in a pattern, It needs to be escaped.

However, in your example, you are using the underscore character as a seperator so you will need to escape the underscore used in 'INSTALL_PREFIX.

Last edited by jschiwal; 04-09-2005 at 06:09 AM.
 
Old 04-09-2005, 07:27 AM   #3
Miro1
LQ Newbie
 
Registered: Apr 2005
Posts: 6

Original Poster
Rep: Reputation: 0
Thanks, I'll try this
 
Old 04-09-2005, 09:02 AM   #4
Miro1
LQ Newbie
 
Registered: Apr 2005
Posts: 6

Original Poster
Rep: Reputation: 0
I've just tested the code, it works great.

Thanks again.
 
  


Reply



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 problem twintornado Programming 2 06-02-2005 08:25 AM
a sed problem thanhVic Programming 5 03-02-2005 01:05 AM
sed problem fossilet Linux - Software 4 12-26-2004 05:44 AM
Help Sed Problem anirudh Linux User Groups (LUG) 1 08-30-2004 02:25 PM
Insert character into a line with sed? & variables in sed? jago25_98 Programming 5 03-11-2004 06:12 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:18 PM.

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
Open Source Consulting | Domain Registration