So, basically you are using the echo command to print 'Hello World'. If you are using a desktop Linux, you may also use a graphical text editor like Gedit to add the text to this file. You can also use a terminal-based text editor like Vim, Emacs or Nano. Press Ctrl+D to save the text to the file and come out of the cat command. Insert the following line in it by typing it in the terminal: echo 'Hello, World!' Now inside this 'scripts directory', create a new file named hello.sh using the cat command: cat > hello.sh Let’s first create a new directory named scripts that will host all our bash scripts. Let me show you how to create a simple bash shell script, how to run a bash script and what are the things you must know about shell scripting.
It may be a simple backup of a directory or it could be cleaning up temporary files or it can even be cloning of a database.Īutomating a task is one of the many useful scenarios where you can leverage the power of bash scripting. You will often find yourself repeating a single task on Linux over and over again.
If you have to do it more than once, automate it!