There is no better skill other than coding. It is linked to every field you name it. I already talked about the benefits of coding.
Now let’s move to the actual topic.
Are you confused between Python and Shell scripting? Whether you should learn first one or second?
As the way Python is dominating in the automation field, is it going to replace shell scripting in the near future?
I have lots of thought about it.
Whether if you have programming experience or new to programming, it is very difficult to choose one programming language to learn out of two languages.
The one which will help you to grow your career.
As I have experience of working on Python and shell scripting language, I can promise to give you detail insight. After that, it’s easy for you to choose one.
In an earlier post, you might have read the 5 simplest programming languages for beginners. It’s a very nice compilation by Scarlett Erin for beginners. In this post, I am writing about Python vs shell scripting.
There are huge numbers of computer languages. Some programming languages emerge over the decades, some vanishes with no time.
Here is one of the comments on my blog. Chehal is a very career-oriented guy and right now he is in dilemma over Python vs Shell scripting.
Do you have the same question?
Choosing the right or wrong programming can change your career either way. It’s not easy. So, I decided to contemplate my opinion by writing this article.
Now let’s talk about Python vs shell scripting.
To give input you should know the difference between Python scripting and Shell scripting.
Table of Contents
Shell is just a programming interface that is useful to access operating system services. And Shell scripting is nothing but writing multiple commands on the shell to complete a certain task.
What are the different shell scripting languages?
When we talk about shell scripting, Bash is considered to be the most prominent Unix shell and programming language.
Apart from Bash, there are many scripting languages such as sh, csh, dash… But, bash is more matured and widely used among all.
Bash is used to writing command-line coding. So, in other words, we can say, bash is command language.
Whereas Python is not a just scripting language, it is a complete programming language.
Why do I call Python a complete programming language rather than just scripting language?
Now consider you have to write code that needs a data structure to store the input or output values.
You can use a variable in a bash script to store a single value. But there is no such advanced data structure privileged such as list, dictionary or set.
These advanced data structures are available in Python.
Python can be used for web development as it has various web development frameworks such as the most scalable Django for enterprise, most lightweight bottle framework for small apps. The wide range of libraries can be useful for data science and data analytics, machine learning, and what not…
Looking at this scalability and use cases, it’s wise to call Python a complete programming language.
Now let’s start differentiating Python Vs Shell Scripting.
Suppose you are writing a script to replaces some string in a file with another string. It is just a couple of lines of code in a bash script.
That, you can also write in Python. And if you are importing any library, it will be even easy to make things work for you.
Other advantages of Python over bash is, there are lots of external libraries you can import and use without any hustle. It reduces your program length and coding effort.
In Python, most of the things you can do by calling a one-line function from the imported library. Isn’t that so easy?
But there are some places you need shell scripting.
Shell or bash scripting is only preferable if you are interested in system administration work. And it is extremely powerful in this field.
Now on another side, if you know both Python and bash script. It will be honey over the bread.
If you are a newbie, I would suggest learning basic bash command that can speed up your productivity working in a Linux environment.
You don’t need to be the God of shell programming unless you are working as a data administrator. Basic commands are enough to improve your productivity.
So command line coding language like bash scripting and complete programming language like Python have their own features to differentiate between them.
Moreover, I would suggest you go and learn both of these computer languages. You can find it very handy and useful if you are primarily working on a Unix or Linux environment.
There are many basic shell commands to start. Use these shell script commands in day-to-day work.
Once you get good hands-on with these basic commands, start using iteration such as loop, while, or piping. Play with an external data source such as contents in a file. Accessing data from a file and manipulating it.
In other words, what are the advantages of Python over Shell scripting?
Up to now, it’s very fine with shell scripting.
Suppose you want to use an array, data structure or you need some data manipulations in your project task. Things will start feeling the heat with bash scripting. And this is where you need to hone some Python skills.
After getting comfortable with shell commands, learn the Python programming language. You will find an improvement in your productivity as you have basic shell commands for quick moves.
I can tell you, whatever you have done with bash scripting you can do the same with Python programming.
Just to give you some example…
Reading .csv files in Python is so much easy if you are using external libraries.
More to that, if you start working on its prominent datatypes like the list, dictionary, set. It will downsize the huge number of lines of code. You will be amazed, how a small line of Python code can make such big things happen.
One of the quick examples is…
You can create an HTTP server in Python with a just single line of code.
In my case, I learned Python first and then started learning bash script. I was so amazed by the Python programming.
But if you are a beginner, according to my experience you should go for bash scripting first. Start using basic bash commands. Then start learning python programming.
Once you learn both languages, you will realize my opinion.
Note: I have differentiated both of these languages depending on their programming capabilities. Nowhere I have considered trends and job requirements. If you are looking for a future job, you can read my post regarding the types of programmers need for a software developer job in the future. You will understand, why I am saying Python is the future programming language.
This is my opinion, and I am sure it will even work for you.
I have shared many Python tricks, and unfortunately, I would not make time to write about shell scripting. Soon I will start writing about shell scripting. If you are a subscriber, you will get all these bash script codes in your email box. If you are not a member of the CSEstack FREE weekly newsletter, don’t forget to subscribe now and start learning.
Pro Tips: If you are learning any programming language, practice as much as you can. Don't keep the code up to you. I strongly suggest share it with your friends. Make use the LinkedIn account or any of your programming group, write over there.
Even you can also write and share your code on the CSEstack portal. There are many authors on CSEstack who share their code and discuss it with other members. Getting other programmers’ comments on your code is a kind of improving yourself. I have shared all my initial learning and Python Tricks on the CSEstack portal. Trust me, if you read any program, you will forget one day. But when you start writing, it will remain with you.
If you have any questions or if you have any doubts, don’t let it burst inside you. It is very harmful. Write in the comment below. Let’s have a fruitful discussion. I would like to help you with my best.
If you make your mind to choose Python, here is you can start learning Python.
Now you have enough to make your choice for Python vs Shell scripting. Kindly do share this with your programming friends as well. It will help them to make their decision and to determine their goodwill future.
Happy Programming!
Excellent Description.Thanks !!!
Glad you like it. Thanks 🙂
Hi Aniruddha Chaudhari,
Very informative.
I am working as an DATABASE ADMINISTRATOR. I really see the importance of scripting, as we need to automate many repeating tasks through scripting. Most of the times using Shell and also need ti put some SQL into to bash.
I hope my requirement is clear.
I am just assuming learning Shell scripting would be good for my requirement.
Let me know if otherwise, and pass on some good resources to start on Shell scripting.
Once again, your explanation is very good.
Thank you,
Regards,
Mahendranath
Hey Hi Mahendranath,
Shell scripting also seems to be a good choice for your requirement. If you are looking for bash scripting, I would like to suggest you https://ryanstutorials.net/bash-scripting-tutorial/ this tutorial.
Moreover, you can use Python as well to interact with the database. Further, If you are looking for data parsing and analysis, Python would be a better choice than a shell script.
Regards,
Ani
hello friend/sir/brother
i started to learn coding from yesterday i dont understand many lines in it can u help me what i hav to do in starting thanks
Hi Arun,
Which programming language are you learning, mate?
And is this your first programming language to learn?
Hi,
I am HR from a product development company in Chennai, looking for a candidate with very good experience in Python, Ansible, Linux and Nagios (Good to have).
Please let me know if you have any reference.
Thanks
Gopa Kumar
Hi Gopa,
We can help you to reach out to deserving candidates through our subscribers.
Please contact here- https://www.csestack.org/contact-us/
Regards,
Ani
I’m learning penetration testing and studying to get my OSCP certification, I am also into IoT as well. I’ve been told multiple times that learning python is a HUGE plus in both of these fields. is there any Python instead of Bash courses out there?
Python is very versatile and I’m sure it can help you in automation testing, IoT development, and many other fieds. Go for it. Here is a complete Python tutorial to follow.
Thank you for this article,
I am a network support rep with my company. We use Aruba OS switches and it’s very clear network automation is the way of the future. I’m just diving into this vast ocean of programming and I would like to implement APIs into my job however I’m not sure if I should pursue Python first or start with Linux to get an overall better understanding of Python. It’s all quite overwhelming. What do you suggest?
Thanks for your kind words. It’s always good to get handy with the Linux OS and commands. But, if you want to Learn Python, learning Linux is not mandatory. You can also learn Python on any OS like Windows, Linux or macOS.
Hi Sir,
6months back I started learning python, “I have zero knowledge about programming”. But stopped after 1month. So, Now again after long research, I came across your blog, The Point included are very valuable…So, I will start with bash & will get to Python.
“The People who are seeking for mentoring when they are in dilemma.. just Your one blog can change their life path”
Sir, Appreciate for all your effort in contributing to New beginners…
Please don’t stop in any difficulty stage sir.
Hi Arun,
That’s really great to know how my blogs are impactful. Thanks for sharing your kind words. It keeps me motivated. Feel free to share your feedback or testimonial. I would love featuring it on our website. Best wishes!