Need help with grep, trying to parse/filter a file...
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Need help with grep, trying to parse/filter a file...
Hi there - hope this an appropirate place to ask for help with this...
I need to extract business name and address information (ONLY) from an HTML file, in order to make a database eventually. In other words, I want to strip all the HTML and other extraneous material from the file, and produce a neat file with only the information I want out the other...I'm thinking a well-designed grep line or 2 will do this for me.
Am I deluded? or is there another more obvious way to achieve the same end?
Any advice appreciated.
Here are some sample lines from the HTML file I'm trying to work from:
I suppose this code will do....
The name of the file which contains the html code should be given as argument...
open(FILE,"<$ARGV[0]");
while(<FILE>)
{
s/\<[\d\D]*?\>//g;
s/\s+/ /g;
print "$_";
}
Try using lynx in dump mode - that should strip out the html for you then you can awk/cut/grep the data easier.
I don't know why you can't post html unless you need to have 5 posts first. E-mail me with the html if you want me to post it in the mean time.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.