Featured Video Play Icon

Shell Scripting in Linux

Introduction

Shell Scripting is an open-source computer virus designed to be traveling by the Unix/Linux shell. Shell Scripting may be a program to write down a series of commands for the shell to execute. It can combine lengthy and repetitive sequences of commands into one and straightforward script which will be stored and executed anytime which, reduces programming efforts.

What is Shell?

Shell may be a UNIX term for an interface between a user and an OS service. Shell provides users with an interface and accepts human-readable commands into the system and executes those commands which may run automatically and provide the program’s output during a shell script.

Types of Shell

There are two main shells in Linux:

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

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

2. The C shell: The prompt for this shell is eighteen, and its subcategories are:

  • The c shell is also referred to as csh
  • Tops C shell is also referred to 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, open a replacement file to start typing a shell script or shell programming, then give the shell permission to execute your shell script and put your script in the situation from where the shell can find it.

Choosing A Text Editor

Shell scripts are text-based files. to start out your scripting journey, choose a text editor that works best for you. Linux distributions accompany pre-installed text editors, but the foremost commonly used ones are listed below:

Let us understand the steps in creating a Shell Script:

  • Create a file employing a vi editor(or the other editor). Name script file with extension .sh
  • Start the script with #! /bin/sh
  • Write some code.
  • Save the script file because of 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.
Mansoor Ahmed is Chemical Engineer, web developer, a writer currently living in Pakistan. My interests range from technology to web development. I am also interested in programming, writing, and reading.
Posts created 422

Related Posts

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top