Created
February 6, 2019 21:45
-
-
Save cicorias/1121c6d9f170d4de1984172b9da1db56 to your computer and use it in GitHub Desktop.
curl and capture both stdout and http status
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #creates a new file descriptor 3 that redirects to 1 (STDOUT) | |
| exec 3>&1 | |
| # Run curl in a separate command, capturing output of -w "%{http_code}" into HTTP_STATUS | |
| # and sending the content to this command's STDOUT with -o >(cat >&3) | |
| HTTP_STATUS=$(curl -w "%{http_code}" -o >(cat >&3) 'http://example.com') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment