これを含むcファイルからヘッダーを抽出する方法は?cファイルからヘッダー名を抽出する正規表現
#include <tema4header9.h>
#include <tema4header3.h>
#include <stdio.h>
#include <longnametest/newheader.h>
#include <net/header.h>
#include "last-test-Zhy3/DrRuheader.h"
#include <last-test-8fF7/a5xyheader.h>
私が使用してみました:
sed -n -e 's/#include[ \t]*[<"]\([^ \/<"]*\/[^ \/]*\)\.h[">]/\1\.h/p'
が、それは唯一のサブディレクトリ内のそれらのために動作します。また、私が入力した場合:
sed -n -e 's/#include[ \t]*[<"]\(([^ \/<"]*\/)+[^ \/]*\)\.h[">]/\1\.h/p'
または
sed -n -e 's/#include[ \t]*[<"]\(([^ \/<"]*\/)*[^ \/]*\)\.h[">]/\1\.h/p'
コマンドはもう動作しません。出力ファイルは次のようになります。
tema4header9.h
tema4header3.
stdio.h
longnametest/newheader.h
net/header.h
last-test-Zhy3/DrRuheader.h
last-test-8fF7/a5xyheader.h
あなたの予想される出力は何ですか? 'tema4header9.h'など。 – Inian