LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General > LinuxAnswers Discussion
User Name
Password
LinuxAnswers Discussion This forum is to discuss articles posted to LinuxAnswers.

Notices



Reply
 
Search this Thread
Old 03-22-2010, 04:09 PM   #1
robiwan
LQ Newbie
 
Registered: Nov 2009
Posts: 1

Rep: Reputation: 0
Shell variables in sed when using paths


A new la entry has been added:

Shell variables in sed when using paths

Quote:
The normal syntax for sed is:

Code:
sed "s/FINDTHIS/REPLACEBYTHIS/"
but when you have a case where REPLACEBYTHIS contains the forward slash character, that syntax will fail.

For example, say that you have a shell variable MY_LOG_PATH=/var/log/here and there is a configuration file containing a setting like

Code:
app.log.path = REALLOGPATH/log.txt
and you want to replace REALLOGPATH by the content of $MY_LOG_PATH.
 
Old 03-22-2010, 07:16 PM   #2
penguiniator
Member
 
Registered: Feb 2004
Location: Olympia, WA
Distribution: SolydK
Posts: 442
Blog Entries: 3

Rep: Reputation: 60
You can use nearly any character to delimit the regex and replacement text. A common replacement for / in sed expressions is #, especially when / appears in the pattern or replacement text.
 
Old 11-20-2012, 09:53 AM   #3
Don Johnston
LQ Newbie
 
Registered: Nov 2012
Posts: 7

Rep: Reputation: Disabled
Smile Sed lead character

I have a sed script which reads sed -e 's/@@/\xOA/g' file1 file2. It results in the file being displayed with the change. How can I have it transfer the file file with the replaced characters in place.
 
Old 01-14-2014, 12:35 PM   #4
sajjad008
LQ Newbie
 
Registered: Jan 2014
Posts: 2

Rep: Reputation: Disabled
ok good
 
  


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
How to use multiple paths in configure env variables radam Linux - Software 4 07-17-2009 03:18 PM
Executable paths and environment variables - troubles the_darkside_986 Programming 8 02-21-2007 11:07 PM
SED and shell variables 3saul Linux - Software 4 12-29-2005 12:37 AM
Insert character into a line with sed? & variables in sed? jago25_98 Programming 5 03-11-2004 07:12 AM
Shell paths Manny88 Linux - General 3 09-25-2003 10:59 AM


All times are GMT -5. The time now is 12:30 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