Is it a waste of time to learn bash in a scripting language?

Source: Internet
Author: User
First, although bash has if_else, you can call the system command. But there are many limitations, such as the lack of multithreading and the absence of libraries. So it is unnecessary to learn bash again using py or ruby. First, although bash has if_else, you can call the system command. But there are many limitations, such as the lack of multithreading and the absence of libraries. So it is unnecessary to learn bash again using py or ruby. Reply: In daily work, a lot of work is very trivial and very detailed. You don't think of any specific small tasks.
In this case, you cannot open vim to write a python script.
Probably not finished yet #! , Shell may have completed the task.

Therefore, shell is used to master various commands and sed awk is used to greatly improve the efficiency of daily work.
I believe that every programmer in Linux has a deep understanding.

A one-time task of a trivial task is handed over to the shell. It is destined to be extended and the code volume is not small. The task to be maintained is handed over to python.
It requires efficient work to be handed over to C. Never conflict. Learning bash is not just about learning bash syntax, but about how to use various command line tools ......
In the end, everything is to improve production efficiency! There are a lot of things, such as py shell and ruby shell. from another perspective, it is shell script that gives you the system utility capability. All installed programs are cleaned and lined up for you to play. Sed, awk, kill, cat, ps, mkdir, rm, rsync ,..... others who are not able to count are fortunate enough to call beautiful girls, while * nix's inherent features (redirection, pipe ...) so that they can work collaboratively (so do one thing, well ).

If your program has a lot of M logic and needs to be oriented to complicated data structures, shell awkwardness will be obvious. In this case, go to sexy Python. Linux and bash should be understood. However, bash syntax is a bit strange (usually c syntax is treated as standard syntax, so a language syntax is strange, that is, this language is far from the c syntax rules ), therefore, to write a good script, it is best to learn a c-based modern language. I am using Python now, and then I need to execute the bash command to call the OS. Basically, all bash commands can be run in the OS. system ("") mode. So far, the only thing I have found is that I cannot use the OS. system is running cd. in Python, OS. chdir ("") to implement bash cd. today, my shell script has successfully operated and maintained 500 servers, including IP address-Based Configuration Modification for peer-to-peer copy virtual machines, component start/stop, log backup, and server running status monitoring. Shell doesn't need a python interpreter at least, and the code is very elegant. You think shell is uncomfortable, but it is still constrained by the framework of traditional imperative programming. Every time I open vim, it's fascinating to see a very simple and green shell. Who else will let me write Java or python for O & M? If you're writing a script that requires long-term operation, it is strongly recommended to use python (or ruby and others). It doesn't mean it will be faster and more convenient, but it will be easier to read and maintain, similar to makefile, etc, the Learning and maintenance costs of the strange syntax and symbols in bash, sed, awk, and make are really less than a few wordings in python, and python can be used to eliminate most of the requirements, otherwise, you have to switch back and forth between bash, sed, and awk.
However, if your script may only run once or run a temporary command, it is very convenient to use bash.
Therefore, bash does not need to be very proficient, but it must be guaranteed to be at a certain level and be differentiated by daily work.
However, you will inevitably encounter the situation of reading and maintaining other people's code, so you should take a rough look, such as the if syntax, as for the-a-o-f in if, you can ask du Niang, of course, it is not a waste of time (otherwise, you will let us use shell in such a situation ...)

Suppose there is a shit on the road. Are you using a shovel (shell) or a shovel (python?
Of course, there will also be dung traps, but most of the time it is lying on the road, it is very likely that someone else has lost it.

And shell is not that disgusting. what about real scripts. debug the program on the * nix server and view the debug or running logs of the program. If you do not understand the shell, Your bash and command lines are poorly designed. But as it is, it is hard for you to learn.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.