簡體   English   中英

如何在bash腳本中grep外部txt文件?

[英]how to grep external txt file in bash script?

我想運行一個腳本,該腳本可以在除我自己以外的其他終端中訪問。 像bash <(curl -s http://domain.com/scripts/hello.sh ),但我需要此腳本來grep一個也位於該服務器上的txt文件,例如domain.com/scripts/stuff.txt。 最好的方法是什么?

嘗試:

curl -s http://domain.com/scripts/stuff.txt | grep "$Hi"

您可以將輸出重定向到本地文本文件,如下所示:

curl -s http://domain.com/scripts/stuff.txt | grep "$Hi" > stuff_that_starts_with_hi.txt

下載一個文本文件,並將其傳輸到grep中:

curl http://domain.com/scripts/stuff.txt | grep foo

您也可以使用wget

wget -qO - http://domain.com/scripts/stuff.txt | grep dat

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM