In Linux how can I fetch an URL and get its contents in a variable in shell script?
You can use curl or wget to retrieve the raw data, or you can use w3m -dump to have a nice text representation of a web page.
$ foo=$(w3m -dump http://www.example.com/); echo $foo
You have reached this web page by typing "example.com", "example.net","example.org" or "example.edu" into your web browser. These domain names are reserved for use in documentation and are not available for registration. See RFC 2606, Section 3.