sed Search and Replace with forward slash "/"

I always enjoy performing search and replace using sed command when I need to edit the same thing over multiple files. Usually the syntax that I use is as follow:

sed -i 's/search/replacement/' *.txt

This will replace all the word "search" with "replacement" in all files that ended with txt. 

But what if you want to replace the word "search" with "replace/ment". You just need to do minor adjustment as follow:

sed -i "s|search|replace/ment|" *.txt

Usually I omit the "-i" first to see the changes on the screen to make sure that the text are replaced properly before adding "-i" to perform the actual changes. 

Until next time!!! 

📚 Want to Learn Docker?

I wrote "Levelling Up with Docker: A Practical Guide to Containers" — a hands-on guide for Linux admins who want to learn Docker without the fluff.

What's inside:

  • Rootless Docker installation (Ubuntu, RHEL, SLES)
  • Container networking, volumes, and Docker Compose
  • Private registry setup and troubleshooting playbook

Get it on Amazon: https://www.amazon.com/dp/B0GGZ76PHW

Comments

Popular posts from this blog

SLES 15 LVM + XFS Without Separate /boot Partition

Docker Rootless on Ubuntu (2026 Guide)

pfSense and scp