It is necessary to receive from curl the answer to the file + time. Now it works like this:

$ curl example.com > file 

It is necessary that the time when the answer was added to the response line.

Something like:

 1234567 16:30:13 

How to do it?

    1 answer 1

    update : replaced > with >> , in view of the additional requirement that appeared: add information to the file , and not overwrite it each time.


    for example:

     $ { curl example.com | tr -d '\n'; date +' %T'; } >> file 

    tr -d '\n' will remove the line break from the curl output (if any).

    • the answer is almost correct, you need to add -s "example.com". How to make the value not overwritten and led the log? - James M
    • without the -s - if the curl program curl something, it will be sent to stderr , i.e. it will not get into your file . - aleksandr barakin
    • one
      so that the lines are added, you need to > replace with >> . - aleksandr barakin 1:56 pm
    • Thanks for the next tip. Thank you for helping everyone on this portal. - James M