1
在我的命令提示符下,我運行了一個grep並得到了以下結果。如何禁止在命令行上發送給perl的管道輸入?
$ 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 -->
正如你所看到的,管道輸入簡單地得到了呼應。如何防止這一點?
在第一個命令中,perl不打印任何東西,但我們看到打印的子字符串。爲什麼? – CodeBlue
@CodeBlue檢查更新 –