Creating Shell Script in Linux/Unix.

Creating Shell Script in Linux/Unix.
Written by Sagar RabidasDecember 4, 2021
5 min read
Shell-scripting
0 VIEWS 0 LIKES 0 DISLIKES SHARE
0 LIKES 0 DISLIKES 0 VIEWS SHARE
Sagar Rabidas

Software Developer

In this blog, we will discuss creating Shell Script in Linux/Unix.

Shell scripting:-

Shell scripting is an open-source laptop application designed to be run by the Unix/Linux shell. Shell scripting is an application to write down a sequence of commands for the shell to execute. It can integrate prolonged and repetitive sequences of commands into a single and easy script that can be saved and executed each time which, reduces programming efforts.

This shell scripting academic enables the analysis of fundamental know-how of the Linux/Unix shell scripting application to advanced ideas of shell scripting.

blogpost

Shell:-

Shell is a UNIX term for an interface between a user and an operating system service. Shell provides users with an interface and accepts human-readable commands into the system and executes those commands which can run automatically and give the program’s output in a shell script.

An Operating is made of many components, but its two prime components are –

  • Kernel
  • Shell
blogpost

A shell in a Linux working device takes input from you in the shape of commands, methods it, after which gives an output. It is the interface thru which a person works on the applications, instructions, and scripts. A shell is accessed by using a terminal that runs it.

Whilst you run the terminal, the shell troubles a command prompt (commonly $), wherein you may kind your input, which is then carried out whilst you hit the enter key. The output or the result is thereafter displayed on the terminal.

Types of Shell

There are two main shells in Linux:

The Bourne Shell: The prompt for this shell is $ and its derivatives are listed below:

  • POSIX shell also is known as sh
  • Korn Shell also known as sh
  • Bourne Again SHell also known as bash (most popular)

The C shell: The prompt for this shell is %, and its subcategories are:

  • C shell also is known as csh
  • Tops C shell also is known as tcsh

How to Write Shell Script in Linux/Unix

Shell Scripts are written using text editors. On your Linux system, open a text editor program, open a new file to begin typing a shell script or shell programming, then give the shell permission to execute your shell script and put your script at the location from where the shell can find it.

Let us understand the steps in creating a Shell Script:

  1. Create a file using a vi editor(or any other editor). Name script file with extension .sh
  2. Start the script with #! /bin/sh
  3. Write some code.
  4. Save the script file as the filename. sh
  • For executing the script type bash filename. sh

“#!” is an operator called shebang which directs the script to the interpreter location. So, if we use”#! /bin/sh” the script gets directed to the bourne-shell.

Let’s create a small script –

#!/bin/sh
ls

Let’s see the steps to create Shell Script Programs in Linux/Unix –

blogpost

shell scripting
linux
unix
0 VIEWS 0 LIKES 0 DISLIKES SHARE
0 LIKES 0 DISLIKES 0 VIEWS SHARE
Was this blog helpful?
You must be Logged in to comment
Code Block
Sagar Rabidas
Software Developer
162 Blog Posts
15 Discussion Threads
Trending Categories
15
Software39
DevOps45
Frontend Development24
Backend Development20
Server Administration17
Linux Administration24
Data Center24
Sentry24
Terraform21
Ansible29
Docker28
Penetration Testing14
Kubernetes16
NGINX19
JenkinsX17
Techiio

Techiio is on the journey to build an ocean of technical knowledge, scouring the emerging stars in process and proffering them to the corporate world.

Follow us on:

facebooklinkdeintwitter

Subscribe to get latest updates

You can unsubscribe anytime from getting updates from us
Copyright techiio.com @2020 Kolkata, India
made with by Abhishek & Priyanka Jalan
Copyright techiio.com @2020
made with by Abhishek & Priyanka Jalan