Often there are questions of the form "How can I do this with x?" where x is some tool such as bash, sed, awk or perl. Are answers to such question based on another tool than x not welcome, e.g. are awk answers to sed questions not welcome?

In my opinion it is good to show alternatives to show that using x is not the only way of solving the problem. An alternative may even be a better approach. Also if the alternative is less fit it is good to know as e.g. a particular users setup might differ such that only particular tools are available or the alternative is clearer in communicating an algorithm solving the problem.

A reason for raising this question is that my answer to How do I write a sed one-liner to add a character after every third character? received a number of downvotes without comments. It uses an alternative tool to the same result as the sed answers. Should such answers be downvoted or deleted?

  • sometimes people ask about X because trivia... or because they know the sed way but want the awk because they're learning... sometimes it's because they think they know what they want and aren't wording it in a way to ask for multiple answers. Sometimes they have constraints which prohibit too many options. Sometimes Perl and Python are overkill. Feb 9, 2013 at 13:56
  • 3
    @xenoterracide, in such a case I'd hope OP states the reason for the restriction (and many do).
    – vonbrand
    Feb 13, 2013 at 4:07
  • Here is a more recent discussion along these lines: meta.unix.stackexchange.com/questions/3677/…
    – Wildcard
    Oct 13, 2015 at 19:45

2 Answers 2


Generally speaking, yes, alternative ways of accomplishing the same task seem not only welcome, but often rewarded.

In the case you point to, there are a couple of mitigating issues:

  1. The question specifically, and repeatedly, asks for a sed response. This means the questioner is clearly seeking to improve their sed knowledge as much as they are trying to solve a problem.
  2. Your answer involves not just a different approach, but one that requires a tool (ruby) that is not part of coreutils and indeed not installed on (any?) systems by default.

I suspect that if only one of those conditions was present, the answer would have either been recieved neutrally, or may have even garnered an upvote. But with both present, you have unwittingly invoked the wrath of the acolytes of UNIX the Wrathful, who is a harsh and unforgiving deity.

  • 1
    Would you like to elaborate on the wrath? As I see it wrath makes sense for answers being plainly wrong (i.e. those who fail to solve the problem or fail to properly communicate a solution) but not really for those that fail by using less appropriate tools or such.
    – N.N.
    Feb 10, 2013 at 13:12
  • 2
    @N.N. In the case you mention, the perfect sed option was already given, so your solution didn't help a lot. Also, your solution is not any cleaner than the sed solutions. If your solution uses an other tools, but is much more efficient in terms of type characters, than it WILL gather upvotes.
    – Bernhard
    Feb 10, 2013 at 16:55
  • 1
    @Bernhard I did not expect upvotes I was just surprised at the number of downvotes.
    – N.N.
    Feb 10, 2013 at 18:10

I would not have down-voted your answer but I would never upvote "that kind of thing" either. Here's why...

Having participated in a lot of different tech and programming related forums over the years, it seems to me that stack exchange has a degree of formality that makes it distinct, in keeping with the goal of producing canonical answers to canonical questions. I am not saying this is better or worse than other forums where more discussion is encouraged, etc. It is just different, it is what people expect here -- and if your experience can be taken as evidence of such, it is what people want.

Part of what makes this different from normative forums is that there is more of an explicit focus on reducing repetition. The ideal question is one which is precise but free from irrelevant details; if you can phrase your question properly, you are more likely to find the same question if it has been asked before, or if it has not and you do post it, someone else is more likely to find it later, and since the answers move up and down according to how they been rated, the idea is that the best answer will rise to the top.

That is in contrast to "normative forums" where a thread is ordered in time and it is considered bad usage to start posting answers to questions you find from two weeks ago. Forums like that are more casual and a greater range of discussion is appreciated.

So, looking at the question, your answer, and the answer that was upvoted and selected, I would say this is the *nix exchange and you should understand the difference between the standard shell based *nix toolkit, which includes sed and fold, and the use of various turing complete (=hefty) language interpreters such as ruby. When I see a lot of questions involving sed and awk, my first thought is always how I would do this -- inevitably, perl -- but the fact that my knowledge of perl has made me disinterested in learning a lot of awk does not make it appropriate for me to say, essentially, "You are wasting your time, just learn perl", because, and this is the major problem with your answer, then I might as well just do the same thing for almost every question (also, see NOTE).

Guess what would happen then? We'd have 17 people suggesting "how you can do this with python", 10 for ruby, 12 for perl, 15 for php, 3 for lisp -- it goes on and on. Why not in java? Erlang? Fortran? This could make for some interesting discussion, no doubt...but it is not a discussion forum. So while I wouldn't personally downvote your answer (it is well written and informative -- but still off topic), I do, I think, understand why people would: because they do not want to see the exchange turn into a cacophony of "alternatives". They want canonical answers to canonical questions.

And when I find one in my hour of need, I am very very very glad for it!

NOTE: It also does not mean that my programmer hack solution to sys admin issues is a really "quality" solution even if it does "work for me to do that". It works for me because I know perl, so I use perl. But I know when I'm doing it that it's a hack, and partially about sparing myself having to learn the proper (ie, canonical) way, which would be more universal and more flexible in the context of a *nix shell. The later is what people most want to find in their hour of need.

  • 1
    I wholeheartedly agree with you. Ever since StackExchange responses started popping up all over the place when you're searching for things I always scratched my head and rolled my eyes when I saw, "...but you should do it in this!" responses. It's like you ask someone how to ask where the bathroom is in Spanish but they say, "Don't say it in Spanish... say it in Mandarin!" Feb 12, 2013 at 10:17
  • 2
    I do not think getting answers with alternative tools is a problem as answers are sorted (by acceptance and votes) and usually the canonical answers ends up at the top. Thus, it is usually easy to find the canonical answer so answers with alternative tools does not work against goal of producing canonical answers to canonical questions.
    – N.N.
    Feb 12, 2013 at 15:52
  • 1
    I'm not saying you should not be allowed to post alternatives. Just that I won't support you because I do perceive them as off topic, and hence it is understandable to me that some people would want to actively discourage it.
    – goldilocks
    Feb 12, 2013 at 16:26

You must log in to answer this question.

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