【发布时间】:2014-02-28 00:17:59
【问题描述】:
我想运行一个脚本,该脚本可以在我自己以外的其他终端中访问。像 bash http://domain.com/scripts/hello.sh) 但我需要这个脚本来 grep 一个也位于该服务器上的 txt 文件,例如 domain.com/scripts/stuff.txt。最好的方法是什么?
【问题讨论】:
标签: linux bash grep hosting cat
我想运行一个脚本,该脚本可以在我自己以外的其他终端中访问。像 bash http://domain.com/scripts/hello.sh) 但我需要这个脚本来 grep 一个也位于该服务器上的 txt 文件,例如 domain.com/scripts/stuff.txt。最好的方法是什么?
【问题讨论】:
标签: linux bash grep hosting cat
下载一个文本文件,并将其输入到 grep 中:
curl http://domain.com/scripts/stuff.txt | grep foo
【讨论】:
试试:
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
【讨论】:
你也可以使用wget
wget -qO - http://domain.com/scripts/stuff.txt | grep dat
【讨论】: