Script for converting html to text

Hi People,

Am trying to convert an html report by copying the script below that was written by someone I don't know. but before I can do anything, I need to understand what every line below is doing so i can adjust it to work for my report. Could some one explain each line so that I can copy the idea and adjust mine. I urgently need help please and am very new to scripting. Am trying to read about each command and i can't seem to arrive at the whole logic.

for I in `find ./ -name tb_report.htm`;
   do

echo "converting" $I;

TMPFILE=`/usr/local/bin/mktemp -t rpt.XXXXXX`;
TMPFILE2=`/usr/local/bin/mktemp -t rpt.XXXXXX`;
chmod 777 $TMPFILE $TMPFILE2;
cat $I|tr -d '_' > $TMPFILE2;
cat $TMPFILE2|sed -e 's/COLSPAN=//g' > $I;
/usr/local/bin/elinks -dump -dump-width 130 $I|sed 's/[ \t]*$//' > $TMPFILE;
echo $TMPFILE;
brn=`cat $TMPFILE |sed -n '5p'|awk -F"  " '{print $15}'`
echo $brn;

mkdir -p  `date +%d.%m.%y`/`echo rep`;
cat $TMPFILE > `date +%d.%m.%y`/`echo rep`/`echo BL011.out,$brn`;
echo "done";
done


Any detailed explanation will be appreciated.

CDD
ackimcAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

liddlerCommented:
for I in `find ./ -name tb_report.htm`; # loop through every file under this directory call tb_report.htm
   do # start loop

echo "converting" $I; #print "Converting" and filename

TMPFILE=`/usr/local/bin/mktemp -t rpt.XXXXXX`;  # create a tempfile
TMPFILE2=`/usr/local/bin/mktemp -t rpt.XXXXXX`; # create another tempfile
chmod 777 $TMPFILE $TMPFILE2; # make both temp files world read- and write-able
cat $I|tr -d '_' > $TMPFILE2;  # use tr to remove "_" character
cat $TMPFILE2|sed -e 's/COLSPAN=//g' > $I; # use sed to remore COLSPAN=
/usr/local/bin/elinks -dump -dump-width 130 $I|sed 's/[ \t]*$//' > $TMPFILE; # use elinks to convert webpage to screen output, and sed to delete from  " \t" to end of line
echo $TMPFILE;  # print first tempfile
brn=`cat $TMPFILE |sed -n '5p'|awk -F"  " '{print $15}'` # use sed and awk to get 15th field of 5th line (brn)
echo $brn; # print 15th field of 5th line (brn)

mkdir -p  `date +%d.%m.%y`/`echo rep`; # create a new directory named after todays date
cat $TMPFILE > `date +%d.%m.%y`/`echo rep`/`echo BL011.out,$brn`; # capy tempfile to new directory into a file named after the brn variable above
echo "done"; # print "done"
done # complete loop



0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
coredatarecoveryCommented:
You could wget the html, and then run a html stripper script on it.
0
ackimcAuthor Commented:
coredatarecovery, do you have any html  stripper script available to play with.
0
a1jCommented:
Lynx will convert it for you for free...

lynx --dump 'URL' > txtfile.txt

0
ackimcAuthor Commented:
Thankyou
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.