How is this question off-topic ? Isn't
grep a utility of Ubuntu and
grep uses regex. Why -6 to this question?
How is this question off-topic ? Isn't
3Read the downvote tooltip: "This question does not show any research effort, it is unclear, or not useful."– SethApr 15, 2015 at 2:00
The question is not off-topic, but downvotes do not only (nor primarily) mean a post is off-topic.
Although we should not close that question and it has value because of the answer that's been posted, the question has two major problems:
It's part of what strongly appears to be a series of "perform this coding (or command-line) task for me" posts, which are not even worded as questions. Check the OP's profile, to verify this. One of them is even multiple choice!
As a secondary but quite overlapping matter, these seem to be homework questions. That is not inherently bad. But the OP has not worded them to ask for help with any aspect of the problem in particular (they are worded as exercises or demands rather than as queries), nor clarified what they are confused about or struggling with, nor provided information about any of their attempts prior to asking.
Questions about grep are on-topic, and this question is on-topic for that reason, but this question is only marginally about grep. Neither
grepnor any Ubuntu-related nor any *nix-related context is mentioned in the body of the question. The question title is "using grep or any of its variations," which is not exactly a clear request for information about grep usage.
The question appears primarily to be an attempt to request help with an exercise about regular expressions, or to mimic such an exercise, i.e., to get us to act as though we're being tested rather than as though we're solving a problem because it actually interested someone or impacted their life. The exercise itself doesn't appear to have been particularly oriented toward the grep utility. It may have arisen in a context of Unix-like systems administration, but if so, none of that context comes through in the question.
As Seth has pointed out, the question may also have received some of its downvotes because no research effort appears to have been undertaken--or, if it was, it was not then reported nor otherwise reflected in the post itself. (This overlaps with, rather than being separate from, the two points detailed above.)
Even if this question were unanswered, it would still be on-topic and unsuitable to be closed--just not by a very large margin. Sufficient information is asked in the question, but obviously relevant information--what is the IP address being used for? and why are the allowed mechanisms for matching it limited to regular expressions?--is absent.
When one is first starting to learn a topic, it's hard to ask really robust, inspiring questions about it. We should keep this in mind when voting, commenting, answering, and otherwise using the site. But this question is a more abject instance of "gimmie code" than most.
Often when people ask basic questions about
grep, they have a broader goal they are using it to achieve. Usually we can at least infer something about that goal by reading the question--for example, someone trying to grep IP addresses from the output of
netstat is likely interested in enumerating TCP and UDP connections. Sometimes the broader goal is simply to learn more about grep (or about regular expressions), which is completely legitimate, but when that happens the question often contains more information about what they were able to do (and when it doesn't, often is about doing something more difficult or complex).
1) This question does not show any research effort -Seth. 2) The question is not off-topic, but downvotes do not only (nor primarily) mean a post is off-topic. -Eliah ...These two sentences are enough. Apr 15, 2015 at 3:04
1Also it's obvious the person is just copying their school homework into the box and hitting enter. Apr 15, 2015 at 16:42