Bash: Display Web Page Content In Terminal

by on August 4, 2013 · 4 comments· LAST UPDATED August 4, 2013

in , ,

How can I fetch HTML web page content from bash and display on screen using shell utilities?

You can use any one of the following tool or combination of all of them to get the contents of a webpage in a shell:

[1] curl command - It is a tool to transfer data from or to a server using http/https/ftp and much more.

Tutorial details
DifficultyEasy (rss)
Root privilegesNo
Estimated completion time10 minute
[2] lynx command - It is a fully-featured World Wide Web (WWW) client/browser for users running terminals.

[3] wget command - It is a free utility for non-interactive download of files from the Web. It supports HTTP, HTTPS, and FTP protocols, as well as retrieval through HTTP proxies.

[4] w3m command - It is a text based Web browser and pager.


Above tools may not be installed on your Linux or Unix like operating systems.

Note: You need to login as root user to install required tools.

Debian / Ubuntu Linux install curl, wget, lynx, and w3m

Open a terminal and and then type:
$ sudo apt-get install curl wget lynx w3m

Fedora / RHEL / CentOS Linux install curl, wget, lynx, and w3m

Open a terminal and and then type:
$ sudo yum install curl wget lynx w3m

FreeBSD Unix install curl, wget, lynx, and w3m (binary package)

Open a terminal and and then type:
$ sudo pkg_add -v -r curl lynx w3m wget


You can use curl command to download the page:


Use curl and store output into a variable as follows:


To display content use echo or printf command as follows:

echo "$page"
printf "%s" $page

lynx command examples

Use the lynx command as follows:

lynx -dump
lynx -dump

The -dump option dumps the formatted output of the default document or those specified on the command line to standard output. Unlike interactive mode, all documents are processed.

wget command examples

The syntax is as follows:

wget -O -
wget -O -

OR use wget command to grab the page and store it into a variable called page:

page="$(wget -O -"
## display page ##
echo "$page"
## or pass it to lynx / w3m ##
echo "$page" | w3m -dump -T text/html
echo "$page" | lynx -dump -stdin

w3m command examples

The syntax is as follows to dump web page content in terminal using the w3m command:

w3m -dump
w3m -dump

OR use w3m command to grab the page and store it into a variable called page:

page="$(w3m -dump"
echo "$page"

Practical examples

Get the definition of linux from a dictionary:
$ curl dict://
Sample outputs:

220 dictd 1.12.0/rf on Linux 3.0.0-14-server  <>
250 ok
150 1 definitions retrieved
151 "linux" wn "WordNet (r) 3.0 (2006)"
    n 1: an open-source version of the UNIX operating system
250 ok [d/m/c = 1/0/30; 0.000r 0.000u 0.000s]
221 bye [d/m/c = 0/0/0; 0.000r 0.000u 0.000s]

Backup your bookmarks:
$ wget --user=Your-Username-Here --password=Your-Password-Here -O my-old-bookmarks.xml
$ more my-old-bookmarks.xml

Grab all .mp3s from url:

mp3=$(lynx -dump  | grep 'http://' | awk '/mp3/{print $2}')
for i in $mp3
wget $i
See also
Tweet itFacebook itG+ itDownload PDF versionFound an error/typo on this page?

{ 4 comments… read them below or add one }

1 Bob August 5, 2013 at 2:53 pm

You can use elinks too; another text web browser.


2 Jalal Hajigholamali August 6, 2013 at 5:02 am


Thanks a lot


3 Curtis August 6, 2013 at 6:14 am

Lets not forget about plain ol’ links as well!


4 Mike Bravog October 20, 2013 at 5:22 pm

As Bob said: elinks too. For me, the best option!

For Debian/Ubuntu series users:

# sudo apt-get install links

That’s all.


Leave a Comment

Tagged as: , , , ,

Previous Faq:

Next Faq: