小编MrC*_*zo'的帖子

使用 -rnw 而不是 -rlw 时 Grep 返回空行

使用这个简单的 Pastebin 测试字符串,为什么与其他两个相比,这里看到的使用正则表达式模式的最后一个示例会给我两个空行?我希望看到与示例 1 相同的结果。请注意,从 example2 到 example3 的唯一更改是从选项 -l 切换到选项 -n。

**example1**
$ grep -rnw html5uploader
    views/layouts/test.ctp:49:       src="/js/jquery.html5uploader.min.js<?=$no_cache?>">
    views/layouts/test.ctp:52:       $("#screenshot").html5uploader(

**example2**
$ grep -rlw .*html5uploader.*
    views/layouts/test.ctp

**example3**
$ grep -rnw .*html5uploader.*
    (empty line)
    (empty line)
Run Code Online (Sandbox Code Playgroud)

文件“test.ctp”的pastebin内容:

<!-- 
        <input type="file" name="screenshot" id="screenshot" multiple />


        <script type="text/javascript" src="/js/jquery.html5uploader.min.js<?=$no_cache?>"></script>
        <script type="text/javascript">
            // File upload
            $("#screenshot").html5uploader(
            {
                name: "screenshot",
                postUrl: "/bugs/ajax_upload_files"
            });
        </script>
 -->    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

grep

3
推荐指数
1
解决办法
2029
查看次数

标签 统计

grep ×1