# Shell Scripting examples

A shell script is a text [file](https://whatis.techtarget.com/definition/file) that contains a sequence of commands for a [UNIX](https://searchdatacenter.techtarget.com/definition/Unix)\-based [operating system](https://whatis.techtarget.com/definition/operating-system-OS). It is called a shell script because it combines a sequence of commands.

How to write and run a shell script

First, you need to open your Linux terminal and then create a Vim file

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1681885939725/dfc96544-f8e1-4b85-97fb-847350f848ac.png align="center")

Then is the syntax for writing a shell script that you need to follow

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1681886181385/45991303-7d59-4eb3-81d3-f8292d96d25c.png align="center")

Now you have to give permission and print syntax

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1681886556217/eaccf779-692f-4cf6-8f76-5fc671f80ef9.png align="center")

Some examples of shell scripting:

1. Print a shell script that is printing "Shell is easy"
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1681889511225/caaf38c4-c8f4-4dbc-bf99-246a29d07f26.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1681889564415/f4e168b1-a7ec-4baa-90a5-46eb08ea0837.png align="center")

1. Holding the variable and printing the variable
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1681889634120/0166a95f-fa3d-4255-bad1-fbc9e1c5331b.png align="center")

1. Taking the name from the user and printing the user
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1681889705290/37654af4-f6f4-44c5-95cb-6741a3111bbe.png align="center")

Print the output

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1681889772824/ffa1551c-1b8a-4086-a23e-95c9bb5031d9.png align="center")

1. Printing the text in the line by line
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1681890203628/58d1b3c3-68dc-4476-820c-727d0058cded.png align="center")
