Shell script to convert HTML file to text file

February 27, 2012 at 23:17:58
Specs: CentOS
I have written a shell script to convert a HTML file to a text file.

But it works only when the HTML file is saved in my system. How do i make it work for an online page?

My code is as follows.

if [ -f /usr/bin/links ]
if [ -f $file1 ]
links -dump $file1 > output.txt
echo "File $file1 does not exist!"
echo "Links is not installed!"

This code works perfectly well when i have a HTML file called "html1.html" saved in my system, but when i substitute the html filename with a hyperlink, it does not work.

For example, if my code is as follows, it does not work.

links -dump > output.txt

However, if i type this same line in my console, it works just fine.

How do i incorporate this command into my script?

Please help.

See More: Shell script to convert HTML file to text file

Report •

February 27, 2012 at 23:38:31
OMG...! What an idiot I've been.

Please don't reply to this post.

I was dumb enough to include the
if [ -f $file1 ]
command in my code.
How can i expect the code to work when this condition is in use? The webpage obviously does not exist in my system.

All i had to do was to remove that line and now it works just fine.

Report •
Related Solutions

Ask Question