Skip to content

Latest commit

 

History

History
46 lines (28 loc) · 1.91 KB

1.md

File metadata and controls

46 lines (28 loc) · 1.91 KB

Chapter 1: Introduction to shell scripting 🚀

1 - The What, Why and How's of scripting

What is Shell Scripting?

Shell scripting refers to the process of writing scripts or programs using shell commands and syntax. It allows users to automate tasks, execute commands, and manipulate files and directories using the command-line interface of Unix-like operating systems.

Why Use Shell Scripting?

Shell scripting offers several advantages, including automation of repetitive tasks, improved productivity, simplification of complex processes, and the ability to customize and extend system functionalities.

How to Use Shell Scripting?

Getting Started with Shell Script

To start writing shell scripts, you need to create a bash program and make it executable. Below are the steps to create and execute a bash script:

  1. Create a Bash Script: Write your script using a text editor.

  2. Make it Executable: Use the chmod command to make your script executable.

chmod +x your_script.sh
  1. Execute the Script: Run your script using the ./ notation followed by the script name.
./your_script.sh

SheBang (#!) in Shell Scripting

The SheBang (#!) is a directive used in shell scripting to specify the interpreter for executing the script. It consists of the # symbol followed by !. In Shell Scripting, when the script starts with SheBang (#!), it instructs the interpreter to execute the script line-by-line.

Syntax:

#!/bin/bash

The above SheBang line denotes that the script should be executed using the bash interpreter located at /bin/bash. This line must be included at the beginning of the script to ensure proper execution.

By following these steps and understanding the SheBang directive, you can effectively start writing and executing shell scripts in Linux.

Next ➡️

Table of contents 🚀