Many questions tagged with bash have accepted answers using sed, awk or common *NIX utilities. Is it OK to use Python to answer questions in the same way?

In particular, I'm looking at this question that wants to randomly bring lines from one text file into another. I first thought of doing something in Python and then turning it into a one-liner, so it can be executed from the command line, but I'm not sure if this is acceptable on the site.

  • 1
    As I'm currently learning python I'm eagerly awaiting your answer there now. ;)
    – dessert
    Commented Dec 17, 2017 at 17:15

3 Answers 3



Often people use when they actually mean – I bet that's what terdon had in mind when he asked about it.

Unless OP explicitly states they need a pure bash solution, answers using external tools like awk, sed and also python are welcome and regularly accepted in the end. And even then: Answers are not for OP alone, but for everybody with the same question. If something else than pure bash is in any way useful to solve the problem. then it's suitable for an answer.

After all, there are few who actually know what is a bash builtin and what's not – a regular Ubuntu user deliberately doesn't have to care about things like that. (There's type to determine that, compare the output of type -a read with that of type -a ls.)

By the way, of the three answers there only one uses bash builtins, and one of the others is by a moderator (watch out for the diamond symbol ♦) – if in doubt, do what terdon ♦ or any other moderator does.


Yes. Definitely. Go for it. Lots of people do that.

Python answers work on Ubuntu, so they are helpful to our visitors. In fact, they might even help people who (shhh!) don't use Linux at all.

Just don't expect to get an accept (imho you should never expect an accept anyway), because Python might not be what the OP had in mind.

  • 1
    Done and dusted... ;-)
    – Elder Geek
    Commented Dec 24, 2017 at 19:01

IMHO tags are only there to help people find the question. Functional solutions shouldn't be avoided simply because they don't match a tag. First of all, questions are often mis-tagged at their inception, and secondly, any answer that results in the desired behavior has value. This is made clear in the guidelines.

Read the question carefully. What, specifically, is the question asking for? Make sure your answer provides that – or a viable alternative. The answer can be “don’t do that”, but it should also include “try this instead”. Any answer that gets the asker going in the right direction is helpful, but do try to mention any limitations, assumptions or simplifications in your answer. Brevity is acceptable, but fuller explanations are better.

Note: or a viable alternative.

You must log in to answer this question.

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