

Let’s look at the syntax of the two sed commands: sed 's/original_string/new_string/' They are both applied to the output of the echo command. I have used two pipes with two sed commands, one to replace the word Athens with Rome and the other one to replace Greece with Italy. ~]$ echo "Athens is the capital of Greece" | sed 's/Athens/Rome/' | sed 's/Greece/Italy/' Then using the pipe I will pass the output of the echo command to the sed command and replace the words Athens and Greece with Rome and Italy. With the echo command I will print the message “Athens is the capital of Greece” in the terminal: ~]$ echo "Athens is the capital of Greece"
#HOW TO WRITE A TREE TO TXT FILE ON MAC BASH HOW TO#
I will start with a simple example that shows how to use the sed command directly in the Linux command line. The sed command stands for stream editor, it’s one of the most powerful Unix tools to filter and transform text. Conclusion Using the Sed Command to Replace a String With a Given Value.Case Insensitive Match to Replace a String in a File.

Replace a String in All Files Recursively using Bash.Replace a String in All Files in a Directory Using Bash.Troubleshoot Why the Bash String Replacement Doesn’t Work.A Simple Bash Script to Replace Strings with Sed.

