-   LinuxAnswers Discussion (
-   -   Shell variables in sed when using paths (

robiwan 03-22-2010 03:09 PM

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.

penguiniator 03-22-2010 06:16 PM

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.

Don Johnston 11-20-2012 08:53 AM

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.

sajjad008 01-14-2014 11:35 AM

ok good

All times are GMT -5. The time now is 04:32 PM.