sed Using different delimiters


Given a file like this:

$ cat file
i am fine

You can use /pattern/ to match specific lines:

$ sed -n '/hello/p' file

If the pattern contains slashes itself, you can use another delimiter using \cBREc:

$ sed -n '\#hello/how#p' file
$ sed -n '\_hello/how_p' file

As defined by POSIX in:

Regular Expressions in sed
In a context address, the construction \cBREc, where c is any character other than backslash or , shall be identical to /BRE/. If the character designated by c appears following a backslash, then it shall be considered to be that literal character, which shall not terminate the BRE. For example, in the context address "\xabc\xdefx", the second x stands for itself, so that the BRE is "abcxdef".