【发布时间】:2017-05-08 23:11:00
【问题描述】:
如何从包含这样的 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,等等……?