0
我试图在变量中存储命令的结果,但无法弄清楚正确的语法。此命令的工作perferctly:将命令的结果存储在变量中
echo "-868208.53 -1095793.57 512.30" | cs2cs +init=esri:102067 +towgs84=570.8,85.7,462.8,4.998,1.587,5.261,3.56 +to +init=epsg:4326
这是怎么了,我试图用这个例子,它适用于我的数据,但outcord
分配是错误的:
#!/usr/bin/bash
filename="$1"
while read -r line
do
name=$line
a=($name)
coord= ${a[1]} ${a[2]}
outcoord= $("echo $coord | cs2cs +init=esri:102067 +towgs84=570.8,85.7,462.8,4.998,1.587,5.261,3.56 +to +init=epsg:4326")
echo $outcoord
done < "$filename"
样的错误,我得到:
remap.sh: line 7: -515561.05: command not found
remap.sh: line 8: echo | cs2cs +init=esri:102067 +towgs84=570.8,85.7,462.8,4.998,1.587,5.261,3.56 +to +init=epsg:4326: command not found
remap.sh: line 7: -515542.01: command not found
remap.sh: line 8: echo | cs2cs +init=esri:102067 +towgs84=570.8,85.7,462.8,4.998,1.587,5.261,3.56 +to +init=epsg:4326: command not found
样本数据:
1 -515561.05 -1166540.03
2 -515542.01 -1166548.76
3 -515519.61 -1166552.19
4 -515505.29 -1166550.25
5 -515477.05 -1166546.82
6 -515431.12 -1166534.06
7 -515411.45 -1166517.39
如何将命令结果分配给变量outcoord
?
我试过了,但仍然收到错误:'remap.sh:line 7:-515561.05:command not found remap.sh:line 8:24d49'46.026“E:command not found' –
啊,我错过了问题在线7.我认为devnull的答案应该可以解决你的问题。 –