[kwlug-disc] wget and variable assignment

Richard Weait richard at weait.com
Thu Jun 3 13:57:20 EDT 2010


On Thu, Jun 3, 2010 at 1:48 PM, Tim Utschig <tim at tetro.net> wrote:

> The newlines are kept, you just need to be sure to quote it:
>
>  $ OUTPUT=`wget -q -O - http://google.com/`
>  $ echo $OUTPUT | wc -l
>  1
>  $ echo "$OUTPUT" | wc -l
>  10
>
> The first is unquoted, and as a result gets split at whitespace
> into separate arguments.  The second gets passed a single
> argument, since it's quoted.  Below shows the argument count:
>
>    $ sh -c 'echo $#' - $OUTPUT
>    244
>    $ sh -c 'echo $#' - "$OUTPUT"
>    1

Excellent.  Thank you!



More information about the kwlug-disc_kwlug.org mailing list