null_reflections
Legendary Coder
I'm trying to figure out how to use sed without erasing extra things that i want to keep in the document. So far, i've realized that sed is largely user-friendly in terms of how it does away with strings and numbers:
in both of these examples, sed will only get rid of entire instances of "10" and "cow", and will not erase every 1,0,c,o,w. However, it doesn't work this way with metacharacters. Let's say i had "**" in a document that i wanted to erase, how do i do that without getting rid of every asterisk? For some reason, it erases all the test in the document when i do
, is it just reverting to the bash wildcard? Why does it do that?
Just to be clear, this works just fine if i wanted to get rid of all the asterisks for some reason:
Code:
sed -i '/cow/d' <file>
sed -i '/10/d' <file>
in both of these examples, sed will only get rid of entire instances of "10" and "cow", and will not erase every 1,0,c,o,w. However, it doesn't work this way with metacharacters. Let's say i had "**" in a document that i wanted to erase, how do i do that without getting rid of every asterisk? For some reason, it erases all the test in the document when i do
Code:
sed -i '/**/d' <file>
Just to be clear, this works just fine if i wanted to get rid of all the asterisks for some reason:
Code:
sed -i '/*/d' <file>
Last edited: