I'm trying to play with sed, to change all;
#include "X"
to:
#include <X>
However I can't seem to find a way to do this! - This is what I've done so far:
sed -i 's/#include ".*"/#include <.*>/g' filename
I think I'm in need of a variable to save the contains of ".*", i'm just unaware of how!
Yes, you do. Regexps use () to save the contents of a match and a \1 to retrieve it. If you use more than one set of (), then the 2nd match is in \2 , and so on.
sed -e 's/#include "\(.*\)"/#include <\1>/g' < filename
will do what you need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With