0

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
8
  • 1
    Have a look at this ... you can't just save JSON output and hope for it to be well-formed CSV. Commented Feb 9, 2021 at 17:06
  • 2
    Please include a small representative sample of what your curl command returns as text, in the post - not as a screenshot of a spreadsheet program. Commented Feb 9, 2021 at 17:14
  • Use jq to get the values you need and output them as csv Commented Feb 9, 2021 at 18:06
  • how can i use jq? can you give an example please? Commented Feb 9, 2021 at 18:12
  • 1
    Post an extract of the json returned by from the curl command. Commented Feb 9, 2021 at 18:15

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.