【问题标题】:using grep command to get spectfic word [LINUX]使用 grep 命令获取特定单词 [LINUX]
【发布时间】:2021-05-03 16:05:09
【问题描述】:

我有一个带有链接的 test.txt 文件,例如:

google.com?test=
google.com?hello=

还有这段代码

xargs -0 -n1 -a FUZZvul.txt -d '\n' -P 20 -I % curl -ks1L '%/?=DarkLotus' | grep -a 'DarkLotus'

当我在终端中键入特定单词(例如 DarkLotus)时,它会检查文件中的链接,并为我提供在测试文件中提供的链接中反映的单词 这里没有问题,问题是我有很多链接,当结果出现在终端时,不知道是哪个站点反映了DarkLotus这个词。 我该怎么做?

【问题讨论】:

    标签: grep xargs


    【解决方案1】:

    试试 -n 选项。它显示匹配行的文件的行号。

    最好的问候, 哈里达斯。

    【讨论】:

      【解决方案2】:

      我不确定你在做什么,但你能把它倒过来吗? grep 默认打印匹配的行。这里的问题是您将来自先前命令的标准输出的输入通过管道传输到grep,并且在grep 处可能缺少上下文。由于您有一个文件可以使用:

      $ grep 'DarkLotus' FUZZvul.txt
      

      如果您也打算按照链接进行操作,那么编写 bash 脚本可能会更容易:

      #!/bin/bash
      
      for line in `grep 'DarkLotus FUZZvul.txt`
      do
        link=# extract link from line
        echo ${link}
        curl -ks1L ${link}
      done
      

      然后你可以让你的脚本接受用户输入:

      #/bin/bash
      
      word="${0}"
      
      for line in `grep ${word} FUZZvul.txt`
      ...
      

      然后

      $ my_link_getter "DarkLotus"
      https://google?somearg=DarkLotus
      ...
      

      然后你可以将txt文件作为参数。

      等等

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-10-21
        • 1970-01-01
        • 2021-03-03
        • 1970-01-01
        • 2013-11-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多