store data in a csv file using the curl command

2.5k views Asked by At

following this image:

leshan-server

through a bash script invoked from the terminal I should store the values ​​of "latitude, longitude, timestamp and speed" in a csv file. However, these values ​​update every 1 second, which is why I wrote the following scrip bash to stop when necessary:

#!/bin/bash

while true;

do curl -s -H "Accept: application/json" -H "Content-Type: application/json" http://172.17.0.2:8080/api/clients/giammi-VirtualBox/6/0 >> myresponse.csv

sleep 1s

done

the problem is that in this way it returns the csv file as follows:

csv

the parameters of my interest are: 0,1,5,6 which correspond to latitude, longitude, timestamp and speed, so what I would like is a representation like:

0,1,5,6
xxx,xxx,xxx,xxx
yyy,yyy,yyy,yyy
0

There are 0 answers