curl - 使用 Awk 或 Sed 与 Curl 进行优化

标签 curl sed awk

我有一个文件 url,输出如下:

//
data = {
    'ip': '',
    'server_ip': '',
    'router_name': 'Banana Hammock',
    'wan_domain': '',
    'wan_gateway': '74.125.224.32',
    'wan_gateway_get': '74.125.224.32',
    'wan_get_domain': 'isp.example.com',
    'wan_hostname': 'MumbaVille',
    'wan_hwaddr': '00:00:00:00:00:00',

我使用此命令来获取 wan_gateway_get:

curl -k http://mumbarouter.com/get.asp?statits | awk '/wan_gateway_get/ {print $2}'

输出:

'74.125.224.32',
=

如何让它输出:

74.125.224.32

谢谢你,祝孟巴快乐!

最佳答案

Make it easy on yourself ...因为分手是如此容易做到:

curl -k http://mumbarouter.com/get.asp\?statits |
  awk -F\' '/wan_gateway_get/ {print $4}'

关于curl - 使用 Awk 或 Sed 与 Curl 进行优化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10605675/

相关文章:

linux - shell 脚本 : sed command is ignoring INFO lines given main 2>&1

sed - Bash中的连接线

regex - 删除第一行直到列中出现正则表达式

curl - Slack not_allowed_token_type 错误 - 如何在命令行上发送消息

php - 为什么 CURL 在我设置了 3000 毫秒超时后会在 1000 毫秒内超时?

json - 使用Sed查找并替换json字段

linux - sed 命令编辑多个文件(插入,替换行)

curl - 映射索引Elasticsearch时间戳定制

php - php脚本是如何执行的

bash - 如何打印某些标签之间的数据?