-
But it depends on what you want to do with it.
-
The basic components of Linux, which are all tempered. Few have been replaced. These basic components include shells.
Python started as a tool for operations. It later developed into a lingua franca. Python can solve the problem that tools such as shells are difficult to program and have poor readability.
Of course, there are many more design ideas in it, so I won't list them. But Python didn't start with the goal of replacing shells.
But Ruby had the idea. Ruby has some tools that clearly want to replace the application's console. It's an ideal language.
as a programming language, not a command-line tool. Python does not have the advantages of strong interaction, versatility, compactness, permission management, batch processing, complex pipelines, security, efficiency, etc.
However, many of the scripts supported by the shell have been replaced by python. Therefore, a large number of Python scripts can be seen in Linux system initialization and operation and maintenance management. For a python veteran, programming with shell scripts is not as good as writing a python script directly.
There is no need to learn two sets of programming methods.
I've been using python for more than 10 years, and I always feel that it is not necessary to write a shell script with more than 50 lines. Having python is enough. It is more common to occasionally write a shell with a dozen lines. Any more will be python.
In some particular operating systems, the GUI has been redesigned, and one of the operating systems does not even have a command line, and is almost completely graphical. There is no shell in these operating systems. It was replaced.
Similarly, if we write an operating system in python, obviously the shell is not needed anymore.
-
Good question, sit back and wait for the master to answer!
-
Write a script with bash to accomplish something. In general, it is almost possible to write scripts with the same functionality in Python. It's just that the syntax and runtime environment are different.
Bash, bourne-again shell, from the earlier bourne shell(sh). Bash's built-in commands are well integrated with the commands that come with Unix Linux (complementary, the command format usage is the same or similar), the environment variables that come with Bash are well integrated with the environment variables of Unix Linux (complementary, help each other, borrow), Bash is not object-oriented, and Bash does not have rich libraries like Python. It's too rich and powerful to be the default shell for Unix Linux.
-
1. For complex logic, Python has the characteristics of modularity, which is better than shell.
2. But for a single command, what is it like to use python, every command has to be called, and python's functions are not separated by spaces like shell, but to add parentheses, commas and quotation marks, the picture is too beautiful I dare not think.
3. So the best solution is to coexist with the two, directly type the command with the shell, and write the script with python. In fact, many Linux distributions come with Python, and it's okay to use Python instead of shell scripting.
-
Absolutely, a shell is a combination of some shell syntax on various Linux commands.
There are two ways to use python instead of shell.
Use the python package directly to complete the work of linux commandsUse python to call shell commands, such as:
import os
ls'If your problem is solved!
If it doesn't work, keep asking!
-
This is a sub-angle. The shell, which serves as the basis for the UNIX-like class, is now not available in a Python replacement. But if you want to use it to get things done, you can use python instead of shell.
-
1. From the perspective of automated operation and maintenance, shell batch processing is regarded as the whole of shell, then python can be replaced.
2. But broadly speaking, a single command that is usually entered also belongs to the shell, which cannot be replaced, and python also needs to call the shell command.
-
Python can replace shell?
No! Shells are ubiquitous in Linux and are overwhelmingly superior to Python when it comes to handling one-line tasks
But when it comes to logic, it's clear that Python has the upper hand!
In other words, you have to master 50% of the shell, and then choose which discipline to further your studies according to your future choice.
If you choose DevOps, then you will further your studies in Python, and if you choose OpenStack, that is, container operation and maintenance, you will have to study Shell
-
Absolutely, the functions of the shell can be realized in python, and the amount is less, the structure is better, and the readability is better; However, the functional shells that Python can achieve are not necessarily possible, such as the socket module for network communication that will be used in operation and maintenance, the Django framework for web, and the psutil module for performance collection, etc., and the shell has a strong dependence on the command of the operating system, and Python can avoid these problems to a greater extent.
At the same time, Python supports multi-process, multi-threading and coroutines, and the program concurrency is above the shell. The core modules of Python are basically implemented in C, so they are very efficient.
-
The system commands invoked by both parties are different, one uses bash or csh, and the other uses python, but both can achieve the same function.
-
Shell scripts are executed through shell interpreters, common shells include bash, sh, etc., python scripts are essentially a kind of shell scripts, but the first line of python scripts has a descriptive statement: !The usr bin env python line tells the shell interpreter that the following needs to be executed by the python interpreter.
-
Shell script is just a simple language, usually used to write some system maintenance and utilities, such as batch retrieval of files, its function mainly relies on the shell script to start other independent programs to complete, such as find, grep and other Linux common programs. Python is a completely modern programming language and environment (such as supporting object-oriented programming), which can do all the functions of the above shell scripts functionally, but more importantly, Python is used in complex applications such as scientific computing and web server applications.
-
Shell and Python are both scripts, shell is not good to learn, you will have a hard time learning python, although they have nothing to do with each other, but at the same time show your learning ability.
Python has its own advantages, and generally speaking, the commands that organize Linux internals use the shell.
-
These two are not comparable.
Shell scripts can only be compared to Python automation, which is more targeted.
Many people use beer to wash their hair, because the home remedies for washing hair with beer are believed to have been widely spread, but for various reasons, there are still many people who have the question of whether it is okay to wash their hair with beer! >>>More
Of course, reading is useful, but the result is your own ability, even if you are a doctorate, you are not capable, it is not the same, maybe you say that some people are still capable without reading, but you want to be a minority after all, will you be that minority? One thing you have to remember is that it's better to read a book than not to read it at all.
I use roses, 70 times more hydrated.
At present, there are still a lot of SMS verification code platforms on the market, some of which are good and some are bad. You can choose local or off-site! >>>More
Sit on the ground with your legs together, your hips and heels as far apart as possible, your upper body leaning back, and your hands behind you for support. >>>More