Text Processing (Grep/Sed/Awk)
Stop sed from breaking when your file paths have slashes
🧩 The Challenge
Trying to swap out a config file path using sed and watching it choke because the forward slashes in the path conflict with the command syntax is maddening. I have spent way too much time escaping every single slash by hand like it is still 1995.
💡 The Fix
Use a different delimiter character instead of the standard forward slash for your substitute commands. It makes your one-liners actually readable and stops the parser from throwing a fit over directory paths.
sed -i 's|/var/www/html/site1|/var/www/html/site2|g' config.yaml
⚙️ Why It Works
By changing the delimiter to a pipe or even a hash symbol, sed treats the slash as a literal character rather than an instruction to terminate the substitute operation. It is a massive quality of life upgrade for anyone doing config automation.
🚀 Pro-Tip: Stick with the pipe character because it is rare to see that in a standard Unix file path.
Linux Tips & Tricks | © ngelinux.com | 8/8/2026
