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.
I have an assignment, and I am looking for some suggestions....
I am given an html file and have to write a script in the BASH shell to parse out some information (IE: an IP address).
My only problem is that sed, grep and all those commands grab the whole line that the pattern is found on. In this case, each line of the html file is very lengthy, there are probably like 3 lines in the whole file.
So using these commands doesn't get me very far. I still have a large block of text stored in a new file, but it does me no good.
I'm not to keen on regular expression syntax anymoe, but basically tell it to replace everything that meets a regular expression that denotes an HTML tag with nothing.
I am doing the same assignment, and I was able to use grep -o [0-9A-Z][0-9A-Z]-go on for 5 more. This works fine, but its the IPs that I can't get. If I do [0-9][0-9][0-9].[0-9] and go on for the rest of the IP search it gives me 255.255.255.255 fine, but it wont give me anything else that has less digits in the IP (24.24.5.22).
My question is, is it possible to put some sort of OR statement between the [0-9]s? for each part of the IP so that it can match [0-9][0-9] for some of them? If I can get this thats all I need.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.