Escape wildchard in sed in BASH

Home > Search
  by

Let's say you have a string of data that contains a wildcard character.

foo="*.example.com"

 

If you want to replace the wildcard character with something else in sed, you'll need to first escape the wildcard character in sed.

echo $foo | sed 's|\*|TEST|'

 

In this example, $foo will be become:

TEST.example.com

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter in the box below so that we can be sure you are a human.




Comments