I found a really great tutorial explaining some practical sed
examples.
The last one (number 10) can be seen below:
$ sed -e 's/<[^>]*>//g'
This <b> is </b> an <i>example</i>.
This is an example.
Can someone please help me through this one?
To summarize where I'm at:
1. I understand : s/x/y/g
is a command telling sed to "globally subsitute the regex x
with the regex y
2. It seems like the -e
flag puts sed in some sort of "interactive mode", from the man
page:
-e command
Append the editing commands specified by the command argument to
the list of commands.
This seems confusing to me because it doesn't seem like we're giving sed
a "list of commands" it seems like we're giving it a "list of arguments" so I'm not to sure on that one.
3. I understand that the first and only <
is nothing more than the single char regex <
, and the last >
is nothing more than the single char regex >
4. I understand that the *
is telling sed to match 0 or more occurances of the pattern before it, which is in this case inside the brackets; however, this is where I'm really confused: can someone please unpack the [^>]*
more for me?
so where I'm really confused on is:
- what's going on with
-e
in plain english? - what's going on with
[^>]*
?
Thanks :)
sed
syntax, understand that removing HTML using simple sed substitutions isn't going to be perfect, ever: stackoverflow.com/a/1732454/308668.sed
could be able to parse it using its other features, though.