linux curl & jq命令
curl
-x IP address 使用代理
-X GET get请求
-X POST post请求
-d 'xxx'post请求传参
-o file name 保存相应内容到文件
-v 显示通信整个过程
-s 不输出错误和进度信息
jq
json提取处理器
练习:
manshuo@Dashuo:~/temp$ echo '{"a":10,"b":20}'
{"a":10,"b":20}
manshuo@Dashuo:~/temp$ echo '{"a":10,"b":20}'|jq .
{
"a": 10,
"b": 20
}
manshuo@Dashuo:~/temp$ echo '{"a":10,"b":20}'|jq '.[]'
10
20
manshuo@Dashuo:~/temp$ echo '[{"a":10,"b":20},{"c":30},{"d":333}]'|jq '.[]'
{
"a": 10,
"b": 20
}
{
"c": 30
}
{
"d": 333
}
manshuo@Dashuo:~/temp$ echo '[{"a":10,"b":20},{"c":30},{"d":333}]'|jq '.[1]'
{
"c": 30
}
manshuo@Dashuo:~/temp$ echo '[{"a":10,"b":20},{"c":30},{"d":333}]'|jq '.[1,1]'
{
"c": 30
}
{
"c": 30
}
manshuo@Dashuo:~/temp$ echo '[{"a":10,"b":20},{"c":30},{"d":333}]'|jq '.[0,1]'
{
"a": 10,
"b": 20
}
{
"c": 30
}
manshuo@Dashuo:~/temp$ echo '{"a":10,"b":20}'|jq '.[]'
10
20
manshuo@Dashuo:~/temp$ echo '{"a":10,"b":20}'|jq '[.a,.b]'
[
10,
20
]
manshuo@Dashuo:~/temp$ echo '{"a":10,"b":20}'|jq '{"f":.a,"f2":.b}'
{
"f": 10,
"f2": 20
}

浙公网安备 33010602011771号