DEV Community

Cover image for Introduction | Shell Scripting
Rahul Mishra
Rahul Mishra

Posted on • Originally published at programmingport.hashnode.dev

Introduction | Shell Scripting

This is a multipart blog article series where I am going to explain the concepts of shell scripting and how to write a shell script in Linux, UNIX or Mac based systems. You can also follow this tutorial blog using windows but for that you have to install a bash from.

This article is introduction article of this series so we will not do fancy stuff here, just basic.

  • To see how many shell are present in your system just type cat /etc/shells in the terminal. After this command you will see the list of different shells present in your system, it depends from system to system. We are going to use Bash for this tutorial but you can follow by using any shell of your choice.
  • Next command I want to show you is which <shell_name>. By this command you will see the directory where your bash is installed/ present.
  • Now, to write a shell script we need a file of .sh extension. We can create this file using this command touch <file_name.sh> Remember one thing when you create a file using touch command by default it does not have execute permission, which means that you can only read and write in that file. To give it the execution permission just type this command in the terminal chmod “+x” <file_name>.
  • Now open the file in your favorite editor and type“echo “Hello World” And then go in terminal and type ./<file_name.sh> You will see an output Hello World in the terminal.

Congrats you successfully write a hello world program in shell.

Practice code file for this article

This was all about the introduction of shell scripting. Hope you liked it and learned something new from it.

If you have any doubt, question, queries related to this topic or just want to share something with me then please feel free to contact me.

📱 Contact Me

Twitter
LinkedIn
Telegram
Instagram

📧 Write a mail

rahulmishra102000@gmail.com

🚀 Other links

GitHub
HackerRank

Top comments (0)