- 论坛徽章:
- 0
|
1. 直接上文件
--------------------file1--------------------
2015-02-03 21:23:07 {"appTeamName":"方正北斗B型设备","callNo":"309790","deviceType":"1",
"gpsId":"13395595019","y":31.86403,"receiveFlag":"0","speed":83.0,"x":117.29631,"id":0}
2015-02-03 21:23:17 {"gpsId":"13395595019","y":31.86373,"insertDate":"2015-02-03 21:23:17",
"insertUser":"test","speed":84.0,"updateTime":"2015-02-03 21:23:19","x":117.29751,"id":0}
.....
2. file1 文件中的每一行, 都 含有 (x,y)的值.
现在想 提取 每一行的 信息 "x":222, "y":3434
命令如下:
cat car | sed -r 's/.*("y":.*[^,],).*("x":.*[^,],).*/\1\2/'
3. 结果不对?
$ cat car | sed -r 's/.*("y":.*[^,],).*("x":.*[^,],).*/\1\2/'
"y":31.86403,"insertDate":"2015-02-03 21:23:07","insertUser":"test","onlineStatus":"1","receiveFlag":"0","speed":83.0,"updateTime":"2015-02-03 21:23:09","x":117.29631,
请 高手指教 |
|