Linux Reader
Access files and folders on Ext, UFS, HFS, ReiserFS, or APFS file systems from Windows

Pew Pew madafakas!

Access files and folders on Ext, UFS, HFS, ReiserFS, or APFS file systems from Windows
Last updated: Jul 29, 2021

5 Basic Shell Script Examples for Your First Script

Here you will find out:

  • how to use shell scripts
  • when DiskInternals can help you

Are you ready? Let's read!

About using shell scripts

It's very easy to create simple and effective Linux shell scripts to handle daily tasks. A little understanding will immediately make you a power user of Linux. Join us for a detailed introduction to Linux shell scripts.

These scripts are very simple to learn and allow users to create powerful commands and execute them on Linux.

Script #1: Hello World

Hello World programs are the most basic programs that help programmers learn a new language. This simple program prints a string “Hello World” to an output. Use an editor like Vim or Nano to create the file hello-world.sh and copy the following lines into it.

Script hello world

After you save this file and exit, you need to launch it with the following command:

Launch file with script hello world

Use it with any of the two commands below:

Launch file with any of these commands

It will print out the string passed to the echo inside the script.

Script #2: For Comments

Comments are highly important for correct code. They are placed in code with the #(hash) that goes before the text and it gives no intervention in script code.

How to use comments in bash code

Again, use # before some lines to indicate comments, please. But the first line is an exception. There it is called a “shebang” to let the system know which interpreter to use when running the script.

Script #3: Echo for Print

The echo command is used to print the information in Bash.

It is similar to the C function "printf" and provides many common options, including escape sequences and redirects.

Echo script for print

You may notice -e in this code. It is used to tell echo that the string that wrote further has special characters and requires more extended functionality.

Script #4: If Else

Bash if else command

The else part needs to be placed after the operation parts of if and fi.

Script #5: Multi-line comments

You can use multi-line comments for shell scripts.

Multi-line comments script

DiskInternals Linux Reader will help your virtual machine and dual-boot

If you’re running Linux on a dual-boot or virtual machine, you can use DiskInternals Linux Reader to easily transfer files, read and mount system files, and more.

This easy-to-use, super-simple, and professional program can help you with all your data transfer needs.

It is a must-have tool for DB and VM users and it will make your life a whole lot easier.

Download DiskInternals Linux Reader today.

Related articles

FREE DOWNLOADVer 4.21, WinUpgrade to PROFrom $29.95

Please rate this article.
52 reviews