I want to print just the HTTP status code for a web page retrieved using cURL. Is it possible to do this with an AWK one-liner?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Solution
The following one-liner will read the HTTP header from a pipe, and print out the status code.
Interesting Aspects
There are a few nice things about this approach that may not be obvious at first glance. For example: