Issue
I have a text with multiple wildcards in it. I want to delete http://*
.
I tried sed -i '/http://*/d' file
, reverse grep but the * is 🙂,
Solution
You need to use
sed -i 's~http://\*~~g' file
sed -i 's~https\{0,1\}://\*~~g' file
Here:
-i
- modifies the file inlines
- defines thes
ubstitution command~
is used as a regex delimiter char (to avoid escaping/
chars in the pattern)http://
matches a literal string\*
matches a*
char (it needs escaping as it is a special regex metachar)g
-g
lobal flag to remove multiple occurrences per line.
In the second command, s\{0,1\}
matches an optional s
in the protocal pattern part.
Answered By - Wiktor Stribiżew Answer Checked By - Terry (WPSolving Volunteer)