Linux Reader 4.0Ext 2/3/4, UFS2, HFS and ReiserFS/4 for Windows
Linux Reader 4.0
Ext 2/3/4, UFS2, HFS and ReiserFS/4 for Windows

All You Need to Know About Bash Script

Here you will find out:

  • how to write bash scripts
  • when DiskInternals can help you

Are you ready? Let's read!

Scripts are used to instruct a computer’s operating system on what to do and what not to do.

Bash scripts are used in system administration and development to instruct the Bash shell on what to do. Bash is available on Linux and MacOS.

About Bash Scripts

Bash scripts contain a series of command-line texts; virtually any command that you can run on the command line can be included in a Bash script. All you need to do is to type the command exactly as you would do in a command-line interface and the code will run the same action when you launch the Bash script. Thus, before you can write Bash scripts, you must know and understand how the command line works.

Honestly, writing Bash scripts for the first time can be breathtaking, but gradually it becomes normal.

How to understand Bash scripts

If you’re a command-line pro, then you probably know a lot about Bash scripts already.

Bash scripts simply let you write commands in plain text format and have them execute the same action as if they were written directly into a command-line interface. However, you should know that your bash script should have a .sh extension or the commands written in the text file may not execute properly.

If you want to understand Bash scripting, you should first understand and master Linux’s command-line interface.

BASH SCRIPT EXAMPLE

Step 1: Creation of my first script

To start writing your first Bash script, you need to get a good text editor, similar to when you’re trying to write software code. Once you’ve got a good text editor, you can start creating your first shell script file, a.k.a. the Bash shell script.

Launch your text editor and type the following commands:

Note: a Bash script has to begin with #!/bin/bash; this will make it clear that you’re trying to run a Bash script. This first line is referred to as a shebang. The second line of your script is a comment; it won’t appear when you run the script. Comments are there to notify others on how to handle a particular part of a script.

Step 2: Get your script permissions

You need to grant some required permissions in order for your Bash script to execute the commands written in it. To make your Bash script executable, simply change the permissions with the code below.

This is done with the chmod command as follows:

The chmod command is used to grant permissions for your Bash file to be executable. Use the "755" command to grant everyone that comes across this script the permission to read, write, and execute your script. Use "700" if you want your script to be only managed by you.

Step 3: Get it in the path

Now that your script is executable, you need to place it in a path. To do this, save your script to a directory on the computer. Depending on the Linux distro you’re running, the command below will help assign your script to a directory.

In the command above, “bash_scripts” is the directory where your new script will be saved.

However, you can create a folder in your bin directory and move your script in there. Most Linux distros allow users to save all their programs in the bin directory to make things easier.

DiskInternals Linux Reader

DiskInternals Linux Reader is a freeware program that lets you view and access files from Linux partitions if you’re running a dual-boot or virtual machine in a single computer system.

Interestingly, this software doesn’t work with any algorithm; it simply lets you access and views Ext4 partitions in a user-friendly explorer similar to Windows Explorer. DiskInternals Linux Reader is a handy freeware tool for everyone running Linux and Windows on the same computer or laptop.

FREE DOWNLOADVer 4.0, Win Upgrade to PROFrom $29.95

0.26928210258484