This question already has an answer here:

I've seen this couple of times: How to foo the bar with X? X being a requirement of the asker. Now, maybe I'm biased by my participation in Software Recommendations where all requirements of OP should be met or at least explain why they couldn't meet them; but why are we answering how to foo the bar with Y?

If OP is interested in accomplish a task with X, for whatever reasons, why are we just forgetting about possible limitations of OP environment and just accomplishing the task? Is this really good practice for us?

marked as duplicate by Michael Mrozek Jun 20 '14 at 14:23

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


I'm on the fence with this as well. I find that when I'm searching via Google for solutions that I'll invariably find answers to questions on one of the Stack Exchange sites, that provides a solution that I was looking for, even though the original question may have specified only a particular X be used.

As to answering the original question that wanted a solution using X, you're correct, it's violating the purpose of the OP asking for a solution using X.

I think this is a community solution and I've left it alone since searching this site would seem to indicate that it's been this way since inception, or closely there after.


Good question. I've seen this pattern quite a lot here: sometimes to constructive ends, sometimes not. The worst are when the resulting answers are just code one-liners. Double ouch!

I would suggest a nuanced approach rather different from Software Recommendations: This can be done but it needs to be justified. The justification does not have to be elaborate, but it should instruct the OP and future readers on the comparative merits of different solutions or tools.

By way of example let me pick on sed for a minute. Lets suppose we have a sample question:

Question: How do I get result X out of dataset Y using sed?

First and foremost a good answer to such a question will start off with a sed solution. Besides a working command, and explanation of the flags or routines used and any special data considerations are in order.

At this point the answerer may wish to provide a better solution as well. Their experience may tell them there is a better way go about solving the problem. Maybe sed is a cumbersome tool for the job at hand. Adding onto the answer with "This would be much simpler in awk. {explanation}." should be perfectly acceptable. In fact this is quite useful. They might even provide several methods and comment on their merits in various circumstances.

It's also possible that sed is not capable of the task and that another solution must be provided. It should be up to the answerer to explain why this is the case and not just leave them hanging by dumping an alternate solution.

Now another answerer comes along. Of course they have the perl solution. Suppose the sed case is already well covered by another answer. I would suggest that in order to drop an answer using a different program than was specifically requested it is incumbent on them to also explain under what circumstances the alternate solution would be more appropriate. If you are going to propose and alternate method, take a second to say something about the strengths or weaknesses of the method as compared to the requested one so that people can make informed decisions about what tool to use. The presumption is that even if the OP does not want to switch tools, some future readers might have a slightly different scenario or different preferences. Addressing these other scenarios is fine as long as they are put in context rather than just lobbed in there.


Answer: Use perl instead: perl -pne '])[{!}+*=!]+*{=]*]'


Answer: Bob's answer shows how this can be done in sed, but as you can see it gets tricky trying to escape all the possible input strings. If you want to sidestep t he whole problem, there is a more specialized tool des that can make this less brittle. Use it like this...

In the mean time don't:

  • …just drop command one-liners with other tools.
  • …ignore the specific scenario and tool questioned.

I don't think failure to follow these suggestions should automatically qualify posts as NAA material, but failure to do it should be a fair point of criticism and OP's should be encouraged to make their posts useful. Failure to put their alternative solutions in context is also a failure to be useful and should be dealt with just like other answers an the site that fail to be useful.

¹ Note this is not bad on account of being perl. I like perl, that's why I feel like I can pick on it. It's bad on account of not explaining when or why to use it, how it works, or how it relates to the requested tool.

Not the answer you're looking for? Browse other questions tagged .