如何从bash中的Json文件中获取单个值?

时间:2018-07-30 18:38:00

标签: shell unix grep

我想从output.txt文件中获取一个值,然后根据返回的值模式运行其他bash命令;

  

cat output.txt enter code here

样品文件数据

{ "Topics": 
  [ 
    { "Name": "arn:aws:sns:us-west-2:123456789012:freezing-deploy-topic"}, 
    { "Name": "arn:aws:sns:us-west-2:123456789012:dense-deploy-topic" }, 
    { "Name": "arn:aws:sns:us-west-2:123456789012:tenki-deploy-topic" } 
  ] 
}

Shell脚本文件

while read line
do 
    if [[ $line =~ 'tenki-deploy' ]]
    then 
        echo "$line"
    fi
done

0 个答案:

没有答案