I read the meta question Are answers using alternative tools not welcome?, but I'm not sure if my question has nuances that the other doesn't. I have no issues if you consider this is a duplicate.

I answered the question Problems iterating over several Bash arrays in one loop with an alternative solution that doesn't address the specific question, i.e. using arrays in . I purposefully used logic and tools not far away of OP's needs: bash and a loop, ruling out arrays. It's not like I proposed a solution with .

My answer aims to solve the underlying goal of OP, wich may be helpful if they didn't think of using different means to solve said goal.

Then I started to doubt if this is appropriate and if is fit to the site's answering policy. Would be this welcomed, encouraged maybe, or should I refrain to do this kind of thing in the future?

  • 1
    As a politeness I think it's good for an answer like this to lead with an acknowledgement that it isn't what the OP specifically asked for and give a very brief summery of why it fits their problem or situation. That just help readers understand the context of your answer. It helps manage the readers expectations and avoid frustration. Mar 25, 2021 at 22:12

5 Answers 5


The premise is that Stack's goal is to build a library of high-quality answers, thus in general I think alternative answers are welcome, as long as they fit the site's scope — here, they should employ tools typical of a Unix system.

In your particular case:

  • The question at hand nicely asks "Some ideas?" at the end, complying with the keep an open mind guideline.
  • Bash, the tool you proposed, is a consolidated Unix tool, obviously.
    • Which is in fact the very same tool the asker is using.

So it cannot possibly be reproved.

On the other hand, some questions are framed as "Why doesn't X work". I don't think it is fine to jump to an alternative approach without explaining why X doesn't work.

For example: What makes grep consider a file to be binary? has a bunch of answers that do not explain what makes Grep consider a file as binary. The accepted answer merely touches the subject without fully addressing it. The only answer that fully explains it is sitting down there in 4th place.


Stackexchange has the problem that it tries, at the same time, to be a platform for

  1. compiling useful information in one place, so that it's useful if found by others later, possibly through a search engine; and

  2. providing answers and useful solutions to the particular cases of the individual askers. This also splits into

    2a. actually answering the question as asked; and

    2b. providing a useful solution.

Now, these are not all the same thing: goal (2b) can be at odds with goal (1), since a question of "How to do X in situation S" can well be answered with "In that case, don't; do Y instead", which isn't very useful for someone who comes later and actually needs to know about X.

When faced with contradicting goals, the only option is to pick the one you feel is best.

So, if one is interested in helping the asker, they should, IMO, do just that, even if it means throwing away some parts of the question as presented. On the other hand, if one wants to collect answers to questions, without regard to their context, they should answer the question as presented.

Of course, there's also the possibility of doing both, but that's more work. In the case where there already are answers filling one goal, providing an answer that fills the other goal would be one choice.

  • 2
    "In the case where there already are answers filling one goal, providing an answer that fills the other goal would be one choice." Totally agreed. I'd say it is perfectly fine to not address the whole question if John Doe has already done it thorougly and one just wants to present an alternative approach. Otherwise, (in my opinion) it is the answerer's duty to at least honestly mention the incompleteness. E.g. Q: "Why X fails and what to use instead?" A: "You can use Y instead, but I do not know why X fails."
    – Quasímodo
    Mar 20, 2021 at 21:36

Often I'm looking for an answer and find, as one of the top Google hits, a StackOverflow or other StackExchange site question very similar to mine. And if none of the answers fit my particular situation, and I'm eventually able to solve my own problem, I'll add my answer to that question that's was high up on the Google search results, for the next guy, with an appropriate disclaimer that it wasn't exactly applicable to the OP.

I would hope that that's a valid use for SO and related sites, and I'd encourage you to continue as well.

  • Thanks for your answer and the encouragement. I always try to think on the next guy/gal also. Mar 27, 2021 at 23:35

My answer aims to solve the underlying goal of OP

If your answer does this, then it is in fact an answer, and therefore we could argue that it is acceptable. Good answers should always start by addressing the OP’s attempt; in this case, other answers have already done this, so we could argue that it is still acceptable.

In fact, your answer would be more than acceptable – it would be encouragedif it was worded better.

From actually reading the start of your answer, it is not clear how any of the issues above have been addressed: your answer lacks context. Its first paragraph is:

Instead of dealing with arrays, I would use a file, which IMO has the advantage of keeping the data apart from the program. Easier to write and maintain.

It would be clearer if it included an explanation at the start:

The other answers have addressed why your attempt with arrays does not work. This answer shows an alternative method to to perform the original task (printing the second and third elements).

This method still uses Bash and loops, but replaces arrays with files. This separates code and data, which makes it easier to write and maintain the code, and easier to change the data.

This makes it perfectly clear that your post is actually an answer, and explains how it fits in with both the OP’s attempt and other answers.


On most StackExchange sites, starting from StackOverflow and Unix & Linux, I usually read all answers until the end. Even the ones that are not upvoted, and also the comments.

They often contain alternative solutions, advice, remarks, reminders, or best practices, and "you have not thought about this".

Which make me feel it is totally appropriate to provide another solution: but you may have to give an explanation why you think it is the / a good or better answer to the OP question.

It may happen that the OP is forced by some untold reason not to use certain tools. However the ones coming after googling, with a similar question to solve, may not have the same constraints as the OP. In which case, alternative solutions are a real plus.

I can't count how many times I have not followed the accepted answer, but an alternative solution that fitted better. A LOT of times.

  • Thanks for your answer. Me too, I try to read all the answers, not just the accepted ones, to find the solution that fits my requirement. In fact, I jump straight to them and barely read the question. Mar 27, 2021 at 23:34

You must log in to answer this question.

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