Reputation: 173
Is there a way for curl to append output to an existing file using --output/-o option without overwriting it? I cannot use redirection:
curl http://url >> file
Because I am using a return code from curl:
response="$(curl --write-out "%{http_code}" --silent --output file http://url)"
Upvotes: 14
Views: 4178
Reputation: 361547
Give process substitution a try.
curl --output >(cat >> file) http://url
Upvotes: 18
Reputation: 246744
It appears not. You can write to a temp file and then append to your actual output file:
tmp=$(mktemp)
trap "rm $tmp" EXIT
response=$(curl --output "$tmp" ...)
cat "$tmp" >> output.file
Upvotes: 3