Get wget output to a variable

How can I do it? I am trying it like this RESULT=`wget $URL`

P.S. - Also any recommended sources for learning shell scripting?

3 Answers

How about:

RESULT="`wget -qO- "
echo $RESULT

Edit: Yeah, that works.

6

The preferred way would be

result=$(wget -qO- )
echo "$result"

(lowercase variable name, $() instead of `` and quoted expansion of the result variable).

For shell scripting with bash and/or POSIX sh, is the guide to read. And there's a lot more useful resources on that wiki, and on . I'm afraid most other resources on shell scripting are garbage, so it's best to stick with those two.

7

in WGET (for WINDOWS BATCH), there is like this:

OtherApplication -arg1 -arg2 > temp.txt
set /p MyVariable=<temp.txt

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like