14

I am running wget through cronjob for executing some script in scheduled manner. Everytime the output is downloaded and saved as new file. I want to append the output to same file. How can I do that?

I am talking about the downloaded content from the URL but not the log of the execution.

Nish
  • 1,067
  • 4
  • 17
  • 37
  • Might be better in this case use **curl** check out this _example_ [link](http://stackoverflow.com/questions/13735051/curl-and-capturing-output-to-a-file) – mario ruiz Jan 13 '16 at 19:56

2 Answers2

34

You can do it using the following command:

   wget <URL> -O ->> <FILE_NAME>
IslamTaha
  • 1,056
  • 1
  • 10
  • 17
  • 1
    Thanks for this, it worked. Not sure why its not selected as the correct answer – Dilaksha A May 04 '17 at 14:26
  • This solution may be not binary-safe. At least in Windows 10, it adds `0x0D` before every `0x0A` in downloaded content. – Paul Melekhov May 22 '20 at 00:01
  • Not working with wget version 1.8.2 on Windows 10, overwrites output file – Rualark Feb 02 '22 at 16:30
  • This is very strange, because `echo 1 >> out.txt` appends file and `wget http://some.com -O - 2>> out.txt` also appends file (not with downloaded file, but with download log). It looks like downloaded file contains some symbol, which prevents append function altogether. A working workaround is `wget http://some.com -O ->out.txt` and then `type out.txt >> log.txt` – Rualark Feb 02 '22 at 16:44
0

My first approach now would be to download it to a file, add the content of the new downloaded file to the previously downloaded file and delete it.

SimonSimCity
  • 6,415
  • 3
  • 39
  • 52