Go Job Hunting at the LQ Job Marketplace
Go Back > Forums > Linux Forums > Linux - General > LinuxAnswers Discussion
User Name
LinuxAnswers Discussion This forum is to discuss articles posted to LinuxAnswers.


  Search this Thread
Old 03-22-2010, 03:09 PM   #1
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

The normal syntax for sed is:

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

app.log.path = REALLOGPATH/log.txt
and you want to replace REALLOGPATH by the content of $MY_LOG_PATH.
Old 03-22-2010, 06:16 PM   #2
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, 08: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, 11:35 AM   #4
LQ Newbie
Registered: Jan 2014
Posts: 2

Rep: Reputation: Disabled
ok good


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 5 04-07-2016 12:22 PM
Executable paths and environment variables - troubles the_darkside_986 Programming 8 02-21-2007 10:07 PM
SED and shell variables 3saul Linux - Software 4 12-28-2005 11:37 PM
Insert character into a line with sed? & variables in sed? jago25_98 Programming 5 03-11-2004 06:12 AM
Shell paths Manny88 Linux - General 3 09-25-2003 09:59 AM

All times are GMT -5. The time now is 09:55 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration