For complete solutions of the amended / updated question cf. the answer of @Cyrus on this page together with the comments for eventual portability tricks. It additionally
- anchors the stream edit expression on
^#include
and
- transforms from
<...>
to "..."
in the matching cases.
A simple context free solution without the later explicated transform to a different search path includes (from <ccHeader,h>
to "Header.h"
)
$> sed 's/<cc\(..*\.h>\)/<\1/g' so_file.cpp
#include <lib1.h>
#include <Lib1.h>
#include <anotherlib.h>
#include <Toto.h>
sed does on my machines not like the notion of at least one any character via .+
so I simply give it ..*
without discussing further ;-)
You will want at least a character for the basename of the header, so a cc.h would be left intact.