Curl --output add to file (without >> redirection)

Is there a way to freeze to add output to an existing file using the --output / -o option without overwriting? I can not use redirection:

curl http://url >> file

Because I use the return code from curl:

response="$(curl --write-out "%{http_code}" --silent --output file http://url)"
+4
source share
2 answers

Try replacing the process.

curl --output >(cat >> file) http://url
+4
source

This is not true. You can write to the temp file and then add to your actual output file:

tmp=$(mktemp)
trap "rm $tmp" EXIT

response=$(curl --output "$tmp" ...)

cat "$tmp" >> output.file
0
source

Source: https://habr.com/ru/post/1683380/


All Articles