Home > Net >  Why does awk 'print' statement ignore the heading in my line?
Why does awk 'print' statement ignore the heading in my line?

Time:04-19

In MDN's command line introduction they print a network response heading to stdout.

curl https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch -L -I | grep location

which returns this:

location: /en-US/docs/Web/API/fetch

My question is why does the awk 'print' statement ignore the header and only print path like below:

curl https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch -L -I | grep location | awk '{ print $2 }'

result:

/en-us/docs/web/api/fetch

CodePudding user response:

you can try

awk '{ print $0 }'

$2 : print the second column $0 : print all columns

  • Related