Strange behavior when parsing result from curl + awk
问题 Using curl on ubuntu I am trying to fetch the Jenkins version inspired by: https://wiki.jenkins.io/display/JENKINS/Remote+access+API In a bash script I do: VERSION=$(curl -k -i -X GET --insecure --silent --header \"Authorization: Bearer $TOKEN \" $URL | grep -Fi X-Jenkins: | awk '{print $2}') echo "__A__[${VERSION}]__B__" But when I run the script I get: ]__B__2.89.2 So for some reason the prefix: __A__[ gets swallowed and the suffix gets turned into a prefix . I have also tried to trim the