Linux sed and awk Cheat Sheet/Use an alternate delimiter

Make path replacements easier to read.

Section: sed Substitution

Use an alternate delimiter

bash
bash
sed 's|/usr/local/bin|/opt/bin|g' paths.txt
Explanation

Alternate delimiters reduce escaping when replacing file paths or URLs.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing sed Substitution
Replace first occurrence per line
Substitute one match in each line.
OpenIn sheetbashsame section
Replace all occurrences per line
Substitute every match on each line.
OpenIn sheetbashsame section
Edit a file in place
Modify the original file directly.
OpenIn sheetbashsame section
Edit in place with backup
Create a backup copy while editing.
OpenIn sheetbashsame section
Delete blank lines
Remove empty lines from output.
OpenIn sheetbash1 tag match
Delete comment lines
Skip lines that begin with `#`.
OpenIn sheetbash1 tag match