[英]how to grep output from command when there is no pipeline key
我試圖通過沒有管道符號( |
)的控制台查找防火牆形式 Linux 框的狀態。 我如何在不經過 output 的情況下完成 grep。
這是我嘗試過的:
grep firewall < ${systemctl > outfile-firewall}
grep firewall < "$(systemctl > outfile-firewall)"
第一行命令與第二行命令有何不同? 我認為您實際上可以使用帶有大括號的文件命令將命令作為 bash 腳本運行。
grep firewall < $(systemctl)
grep firewall < "$(systemctl)"
有關命令的所有輸出都給出“不明確的重定向”或“沒有這樣的文件或目錄”。 我知道我做錯了什么,但它應該是通過管道 grepping output 的一個很好的選擇。
您可以嘗試 bash 進程替換:
$ grep firewall <(systemctl)
ufw.service loaded active exited Uncomplicated firewall
如果您的系統中缺少 pipe 符號,您可以將 output 放入臨時文件,然后從那里放入 grep。
systemctl > ctl-output-file
grep firewall ctl-output-file > required-output-file
希望有幫助。 祝你有美好的一天 !
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.