使用bash curl时填充变量

时间:2017-05-29 06:45:16

标签: bash curl reverse-geocoding

我很难弄清楚为什么我的变量$ {coor1}和$ {coor2}在这个卷曲中使用时没有填充

卷曲本身适用于静态坐标,但与变量一起使用时,任何人都可以指出我正确的方向,提前感谢:)

coor1=55.860734
coor2=9.808663

stored_address=$(
  curl -s "http://maps.googleapis.com/maps/api/geocode/json?latlng=${coor1},${coor2}&sensor=false" |
  grep -B 1 "route" |
  awk -F'"' '/short_name/ {print $4}')

echo "stored address = ${stored_address}"

1 个答案:

答案 0 :(得分:1)

尝试下一个微小变化:

coor1=55.860734
coor2=9.808663

stored_address=$(curl -s "http://maps.googleapis.com/maps/api/geocode/json?latlng="$coor1","$coor2"&sensor=false" | grep -B 1 "route" | awk -F'"' '/short_name/ {print $4}')

echo "stored address = "$stored_address

输出

stored address = Islandsvej