• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 594
  • Last Modified:

path name substitution in sed.

I want to substitute each occurence of ROOT with the
actual name.

For eg. My file name contains.

help_dir="ROOT"
lic_dir="ROOT".

I want to substitute this ROOT with for eg. /home/user2/tmp.
With sed Iam able to use substitution with out a back slash.

I do not want to use perl or awk.

Can some body help me doing this.
0
meerak
Asked:
meerak
  • 2
1 Solution
 
ozoCommented:
sed s:ROOT:/home/user2/tmp:g
0
 
fredfanCommented:
dear ozo,

try this, sed -e "s/ROOT/\/home\/user2\/tmp/g"

let me know if you have any more problems

fred
0
 
fredfanCommented:
sorry, it was suppose to dear meerak,

try this, sed -e "s/ROOT/\/home\/user2\/tmp/g"

let me know if you have any more problems

fred
0
 
meerakAuthor Commented:
Actually I had already accepted ozo's answer. I thought I have
given points to him already. But I think something went wrong.

I can't use fredfan's suggestion because, the string to be
substitued is a shell variable and I do not know how many
"/" it contains. So I cannot escape it with \.

ozo's suggestion works out.
0

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now