I am having some trouble using sed to replace lines in files.
What i want is to switch out all occurrences of #include <path/to/my/file.h>
with #include "file.h"
using regex.
when I test it with echo it gives me the output I'm looking for:
echo "#include <path/to/my/file.h>" | sed -E 's/^(#include.*[\/<])([^\/\<]*\.h)(>)$/#include \"\2\"/g'
But when I run it with a file containing #includes, it changes nothing. I feel like I have tried everything I can find online and nothing makes any difference
Here is the line I use when I try changing lines in a file:
sed -E -i '' 's/^(#include.*[\/<])([^\/\<]*\.h)(>)$/#include \"\2\"/g' /path/to/my/file.h
edit: Fixed by removing ^ and $ at the begining and end of the regex statement