卷曲和grep状态代码以及文件内容 [英] Curl and grep status code and content of the file

查看:81
本文介绍了卷曲和grep状态代码以及文件内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用grep匹配第一行(包含状态代码)时,是否可以卷曲和grep表达式? (不将卷曲结果保存在文件或变量上.)

Is there way to curl and grep for an expression while matching a first line (which contains status code) using grep? (Without saving the result of the curl on a file or a variable.)

我正在考虑使用grep-

I am thinking some thing like this but using grep -

curl -is "http://example.com/test.html" | awk 'NR == 1 || /'"JOB_STATUS"'/'

使用head和grep

using maybe head and grep

  head -n 1 and grep -E "exp[ab]"

推荐答案

如果您的curl输出看起来像这样:

If your curl output looks something like this:

Status:200
something ... something
JOB_STATUS

您可以使用:

curl ... | egrep "Status:|JOB_STATUS"

获得第一行和JOB_STATUS行.

to get the first line and the JOB_STATUS line.

或者,当您对awk感到不适时,也许是sed,如下所示:

Or, as you have something against awk, maybe sed, like this:

curl ... | sed -ne '1p' -e '/JOB_STATUS/p'

我认为您需要显示curl命令的输出并解释awk的问题...

I think you need to show the output of your curl command and explain what's wrong with your awk...

这篇关于卷曲和grep状态代码以及文件内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆