curl only write to file if successful status 200
- 18 Sep 2017: Post was created (diff)
Make curl get the contents of a URL and write to file, but only write to file if the response is successful:
curl -s -S -f -o facebook-feed.json "$facebook"
-s
keeps curl quiet by hiding progress meter and error messages-S
shows an error message if it fails (stderr)-f
Fail silently (no output at all) on server errors, keeping stdout clean-o
specifies an output file
If you have any comments or feedback, please send me an e-mail. (stig at stigok dotcom).
Did you find any typos, incorrect information, or have something to add? Then please propose a change to this post.