Re: Replace command

"Tim Chase [email protected] [sed-users]" <[email protected]>
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
On 2015-04-08 03:27, [email protected] [sed-users] wrote:
> How replace pattern by other in the variable and with special
> chars. Below one example. 
> 
>  var="DeviceURI smb://text:XptO%232015%[email protected]/RJOMK0202"
> 
>  command executed
> 
>  sed -ri "s/DeviceURI.+/${teste}/" <file>

I presume you mean "${var}" instead of "${teste}".

You have two options:

1) escape all the "/" characters in $var so that the become "\/"

2) use a delimiter that doesn't appear in your $var.  In the above
case, you should be able to do something like

  sed -ri "s#DeviceURI.+#${teste}#" <file>

since "#" doesn't appear in $var

-tim
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.