curl 和 grep(?) 来抓取特定的字符串 - 如何?

jog*_*900 2 scripting curl

我需要使用 curl 对我们的网络农场进行一些测试。每个服务器都有一些默认页面,上面有一些像这样的措辞:

"Welcome to webappsrv01"
"Welcome to webappsrv02"   and so forth.
Run Code Online (Sandbox Code Playgroud)

我如何使用 curl 和 grep(?) 来获取“Welcome to webappsrv(?)”字符串,以便我可以在点击 webfarm 时在屏幕上看到它的输出?我需要知道我打的是哪个服务器。

Mat*_*tej 5

用:

curl -s https://example.com | grep -o "This doma.."

输出:

This domain

选项:

  • -sin curlis silent mode- 它不会打印进度

  • -oin grepis only matching- 只打印匹配的字符串

  • This doma是模式,两个点..意味着任何字符都可以在那里,所以在你的情况下它将是两位数