http - echo in shell script replaces variable with following characters -
when using curl
, awk
content-length http request, resulting variable gets "erased" when used in echo
statement following characters.
why?
#!/bin/sh conf_core_url="http://www.google.com/" cmd_size_target=$(curl -ss -i $conf_core_url | awk '/content-length/ {print $2}') echo "${cmd_size_target}" echo "${cmd_size_target} test" exit 0
expected output:
222 222 test
actual output:
222 test
$cmd_size_target
has \r
@ end need strip first.
Comments
Post a Comment