在我的命令提示符下,我运行了一个 grep 并得到了以下结果。
$ grep -r "javascript node"
restexample/NewsSearchService/V1/madonna_html.html:<!-- start empty javascript node for popup app fix -->
restexample/NewsSearchService/V1/madonna_html.html:<!-- end empty javascript node for popup app fix -->
现在,假设我想删除 " restexample
" 部分。我可以通过使用
print substr($_,13)
但是,当我通过管道传输到 perl 时,这就是我得到的 -
grep -r "javascript node" | perl -pe ' print substr($_,11) '
/NewsSearchService/V1/madonna_html.html:<!-- start empty javascript node for popup app fix -->
restexample/NewsSearchService/V1/madonna_html.html:<!-- start empty javascript node for popup app fix -->
/NewsSearchService/V1/madonna_html.html:<!-- end empty javascript node for popup app fix -->
restexample/NewsSearchService/V1/madonna_html.html:<!-- end empty javascript node for popup app fix -->
如您所见,管道输入只是得到了回显。如何防止这种情况?