Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何编写 linux 的 grep 正则表达式来匹配这样的多行注释
/* comment body */
因此 grep 在上述情况下匹配 4 行。请注意,注释的任何单行都可以以白色字符开头(例如制表符或空格)
我不介意正则表达式模式是否也匹配单行注释
但这不是必需的,因为我已经有一个解决该需求的模式。
如果使用 grep 匹配多行命令不可行,那么我可以使用 sed、awk 等。但首选带有正则表达式的 grep。