Re: sed – using variables containing "/"
- From: Avi Greenbury <lists@xxxxxx>
- Date: Sun, 12 Feb 2012 19:22:34 +0000
Johnny Rosenberg wrote:
So, if the variable MyVar contains a ”/”, sed will fail and a
workaround is to use another character instead of the ”/” character
for sed, like in this case, ”@”.
Yeah, rather than s/4\/3/four-thirds/ one might do s@4/3@four-thirds@
Is this the only workaround in this case or is there a more elegant
one? The variable ”MyVar” must not be changed in any way, other than
that, everything is allowed, I suppose…
If you can't escape it, then yeah that's all you can do in sed as far
as I'm aware. That doesn't strike me as particularly inelegant
(especially considering how much I use sed for changing filepaths) - is
there some other reason to not do it that way?
If you want to be more flexible, though, and so permit all characters
in the strings (or at least not need to predict what might be in them)
it would probably be easiest to pipe it into a perl one-liner.
--
Avi.
--
ubuntu-users mailing list
ubuntu-users@xxxxxxxxxxxxxxxx
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
- Follow-Ups:
- Re: sed – using variables containing "/"
- From: Johnny Rosenberg
- Re: sed – using variables containing "/"
- References:
- sed – using variables containing "/"
- From: Johnny Rosenberg
- sed – using variables containing "/"
- Prev by Date: RE: Athlon II x4 620
- Next by Date: Re: Ubuntu won't detect my GPU (NVidida 520m 1GB)
- Previous by thread: sed – using variables containing "/"
- Next by thread: Re: sed – using variables containing "/"
- Index(es):
Relevant Pages
|