LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 09-10-2004, 12:26 AM   #1
virendratp
LQ Newbie
 
Registered: Jul 2004
Posts: 20

Rep: Reputation: 0
sed question


Hi all,
I am facing a problem with sed. I want to replace a constant string with an environment variable $BASEDIR.
I tried
sed -e "s/this/$BASEDIR/g" temp.txt
sed -e 's/this/'"$BASEDIR"'/g' temp.txt

but it gives me an error
sed: -e expression #1, char 13: Unknown option to `s
for both the cases.

Any help would be appreciated.

Thanks.
 
Old 09-10-2004, 02:50 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 680Reputation: 680Reputation: 680Reputation: 680Reputation: 680Reputation: 680
The problem is due to the variable containing a forward slash, which is what you are using a a separator in the sed command. Try this instead:
sed -e 's#this#'"$BASEDIR"'#g' temp.txt
 
Old 09-10-2004, 02:53 AM   #3
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400
Please use the search function this forum provides before posting, I answered this question twice in the last 48 hours......

http://www.linuxquestions.org/questi...hreadid=227588
http://www.linuxquestions.org/questi...hreadid=228454

Hope this helps.
 
Old 09-10-2004, 03:21 AM   #4
virendratp
LQ Newbie
 
Registered: Jul 2004
Posts: 20

Original Poster
Rep: Reputation: 0
it works jschiwa.
I did try to search but couldnt relate the things that were there to my problem so this post.

Thanks for the replies.
 
  


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 question ckoniecny Linux - General 3 11-11-2005 09:31 AM
question on sed tifu Linux - Newbie 3 03-18-2005 04:38 PM
sed question dolvmin Linux - Software 4 03-09-2004 09:27 AM
little sed question freelinuxcpp Linux - Software 3 01-20-2004 07:36 AM
sed question zoomzoom Linux - Software 2 10-20-2003 04:04 PM

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

All times are GMT -5. The time now is 11:51 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
Open Source Consulting | Domain Registration