【问题标题】:how to grep external txt file in bash script?如何在bash脚本中grep外部txt文件?
【发布时间】: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


    【解决方案1】:

    下载一个文本文件,并将其输入到 grep 中:

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

    【讨论】:

      【解决方案2】:

      试试:

      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
      

      【讨论】:

        【解决方案3】:

        你也可以使用wget

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

        【讨论】:

          猜你喜欢
          • 2012-10-22
          • 1970-01-01
          • 2023-03-30
          • 1970-01-01
          • 2016-12-05
          • 2013-05-30
          • 2013-09-12
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多