我希望在文件中搜索域名和IP地址以及其他一些特定字词,例如POST,GET和其他一些字词。我目前正在使用以下命令:
grep --color -i -f search-terms strings.txt
搜索字词的示例:
<!-- url -->
[[:alpha:]][[:alnum:]\-]*\.[[:alpha:]][[:alnum:]\-]*\.[[:alpha:]][[:alnum:]\-]*$
<!-- ip address -->
[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}
<!-- useful words -->
http
post
get
它似乎工作得相当好,但是如果我在搜索词文件的开头加上 http 这个词,我会得到一个段错误。这是我的示例strings.txt。
hello world this is a search
for anything like a domain such as http://www.me.com
and something else like the word GET
http://google.com
Here is an IP address 10.0.0.1
Here is the word POST.
错误:
$ grep --color -i -f search-terms strings.txt
for anything like a domain such as http://www.me.com
and something else like the word GET
http://google.com
Here is an IP address 10.0.0.1
Segmentation fault: 11