【发布时间】:2016-07-27 11:28:30
【问题描述】:
所以我正在查询以获取我的 gps 位置。 shell脚本命令是这样的:
curl -s http://whatismycountry.com/ | sed -n 's/.*Coordinates \(.*\)<.*/\1/p'
然后将坐标保存到我写的 .csv 文件中:
curl -s http://whatismycountry.com/ | sed -n 's/.*Coordinates \(.*\)<.*/\1/p' | sed -e 's/.*\[\([^ ]*\) \([^]]*\)\].*/\1,\2/' > cordinates.csv
这给了我一个带有坐标的 csv 文件。 the image of the .csv file pattern
现在查询处于无限循环中,其目的是每次查询时都应将新坐标保存到下面的下一个块中。
如何在脚本中编写上一个命令中的正则表达式部分?
感谢您的大力帮助。完全是正则表达式的菜鸟。
【问题讨论】: