How to use Linux Shell Scripting

Linux shell scripting is basically a file that contains script, with this script you can give your shell permission to execute it. This is the example of how to install the bash shell if there is no scripting shell in your unix/linux terminal.

  • How to get your scripting shell

First you need to type apt-get install vim for linux or sudo apt-get install vim for unix

  • Now get into scripting

To start scripting you can type vim project_name, you can change the project_name with whatever project name you want. In this example I use test as my project_name.

  • So this is how bash shell would looked like

  • This is how you can type in the script, an array of ASCII code

To do this you could go to insert mode by typing i on the keyboard.

To exit the insert mode just press esc on your keyboard.

to save, exit the insert mode and type :wto Quit the bash shell, you can type :q! when you are not in the insert mode

The test file that I have created using vim command can be seen below

When you want to go back and edit it via bash shell you can always use the vim command and type name of the file.

Below is the command when you want to save and quit. You just have to exit the insert mode and type :wqbelow is the example of executable file that will print Hello World if you execute the file.

To execute the file you can use ./project_name. In my case the name of the project is test. below is the example of the output.

This is several command that might help you when you do a scripting. Type and enter it when you are not in the insert mode and see the differences.

If you would like to see more scripting example from basic to advance you can visit this link below:

Bash scripting Tutorial

Hope it’s helpful.