Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Here is an often used example of escaping a the / (slash) reserved character within the single quote,

Code Block
languagebash
sed -i 's/original\/path/new\/path/' notes.txt # need to write example hereescape '/' since we are using it as a separator


However, sed permits any character other than backslash or newline to be used instead of the forward slash. For example, the above example may be rewritten as follows to avoid needing to escape the forward slashes (sometimes referred to as "picket fences"):

Code Block
languagebash
sed -i 's,original/path,new/path,' notes.txt # do not need to escape '/' since we are using ',' as a separator


References

Simple introduction - http://www.grymoire.com/Unix/Sed.html
Another introduction - http://lowfatlinux.com/linux-sed.html

...