Python 和/或 Perl VS bash

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4701766/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 23:16:25  来源:igfitidea点击:

Python and/or Perl VS bash

pythonperlbashadmin

提问by webDevelSouth

I normally code admin scripts in Python and I know of many that code them in Perl. I was about to invest some time on improving my skills on bash programming. But I wonder if people around think that this is a good idea ?

我通常用 Python 编写管理脚本,我知道很多人用 Perl 编写它们。我正准备投入一些时间来提高我的 bash 编程技能。但我想知道周围的人是否认为这是个好主意?

I know bash is a good skill to have and market very often demand it but ... if I can get by with Python or Perl then ... is it really worth the effort ?

我知道 bash 是一项很好的技能,市场经常需要它,但是……如果我可以使用 Python 或 Perl,那么……它真的值得付出努力吗?

As answers I am looking for cases where actually bash is way better than Perl or Python to develop admin scripts.

作为答案,我正在寻找在开发管理脚本方面 bash 实际上比 Perl 或 Python 更好的情况。

采纳答案by drrlvn

Anything you learn can only benefit you, neveris it a bad idea to learn something. That said, if you feel you're productive with Python then I don't see why you would need bash. Python is more powerful (being a full blown programming language) and IMO has a nicer, more readable syntax. Bash isoften useful for quick and dirty scripting, though.

你学到的任何东西都只会让你受益,学点东西从来都不是坏主意。也就是说,如果您觉得使用 Python 很有成效,那么我不明白您为什么需要 bash。Python 更强大(作为一种成熟的编程语言)并且 IMO 具有更好、更易读的语法。击经常用于快速和肮脏的脚本是有用的,但。

If you do decide to learn it, here are some resources to get you started:

如果您决定学习它,这里有一些资源可以帮助您入门:

  1. A Bash guide for beginners
  2. The magnificent Bash FAQ
  3. Common Bash Pitfalls
  1. 初学者的 Bash 指南
  2. 宏伟的 Bash 常见问题解答
  3. 常见的 Bash 陷阱

Although some rules-of-thumb are occasionally thrown in the air regarding when you should use each, I think you'll figure it out once you get to know all of your options. Having another tool in your arsenal is always an advantage.

尽管关于何时应该使用它们的一些经验法则偶尔会被抛诸脑后,但我认为一旦您了解了所有选项,您就会弄清楚。在你的武器库中拥有另一种工具总是一个优势。

回答by Mahdi

I'd say if this is only your machine and you're not supposed to share those administration scripts with any other one, so you'd better to keep doing that in Python (which seems you feel more comfortable on that).

我会说,如果这只是您的机器并且您不应该与任何其他机器共享这些管理脚本,那么您最好继续在 Python 中执行此操作(这似乎让您感觉更舒服)。

But if you have colleagues or your admin scripts are supposed to employee by other people, so let keep it in a way that is more popular and more understandable for others also: Bash!

但是,如果您有同事,或者您的管理脚本应该由其他人使用,那么让我们以一种更受欢迎且对其他人更容易理解的方式保持它:Bash!

Also I guess if you know Bash, you can simply use dozens of existing Bash scripts by customizing them or improving them to whatever which is more suitable for you!

此外,我想如果您了解 Bash,您可以通过自定义或改进它们以使用更适合您的任何现有 Bash 脚本来简单地使用数十个现有的 Bash 脚本!