Shell Scripting Languages Examples, Bash, Sh, Python, Powershell, MSDOS, PHP, Tcl, Perl – POFTUT

Shell Scripting Languages Examples, Bash, Sh, Python, Powershell, MSDOS, PHP, Tcl, Perl


A scripting language is a programming language supports writing simply to medium level applications in operating systems like Linux, Ubuntu, Debian, CentOS, Windows, MacOS, BSD, Unix. Scripting languages can be used to run complex tasks automatically or manually with very little effort. We can describe actions in a scripting language and run them easily. In this tutorial, we will look at popular scripting languages used by different operating systems and platforms.

Bash

Bash is the king of the scripting languages. bash provides very convenient programming features. Linux, Unix and BSD platforms fully support bash. If you want to learn more about bash look following the tutorial.

Bash Tutorial

Following bash script will print Hello World to the standard output which is terminal in most cases.

#!/bin/bash

echo "Hello World"

Sh

sh is the limited version of the Bash . It provides basic features for the scripting environment. We can use sh in most of the daily operating like Bash . The following example will print Hello World to the terminal.

#!/bin/sh

echo "Hello World"

Python

Python is a popular programming and scripting language used in different platforms and applications. Python can be used to develop Desktop Applications, Web Applications, Scripts, Cloud Applications etc. There are a lot of ready to use Python scripts to be used in Linux, BSD, Unix, Windows, MacOS. Python provides a full feature set of programming languages. Python has two main versions numbered as 2 and 3.

Python Tutorials

In this example we will print Hello World to the standard output.

#!/usr/bin/python3

print("Hello World")

MS-DOS

MS-DOS is actually an operating system used 1980’s and 1990’s actively by Microsoft. But with GUI based operating system it’s used as an auxiliary tool for low-level operations like scripting and issuing commands. MS-DOS provides some programming features and structures. In this example, we will print Hello World to the MS-DOS command prompt.

> echo "Hello World"

PowerShell

Powershell is the next generation programming and scripting language used by Windows operating systems. It has some basic support for Linux platform too. PowerShell has bindings with programming languages like C# and Visual Basic.Net. In this example, we will print Hello World to the screen.

PS> Write-Output "Hello World"

Perl

Perl is an old friend of Unix and Linux system administrators. As it is not so much popular currently there are popular applications developed with Perl. We can print Hello World to the terminal in a Perl script like below.

#!/usr/bin/perl
print "Hello World"

PHP

PHP is a web-oriented programming language. PHP is designed as scripting language like Python. We can also use PHP as a system scripting language. We will print Hello World in this example.

#!/usr/bin/php

echo "Hello World"

LEARN MORE  How To Set, Get and Change Bash Environment Variable?

2 thoughts on “Shell Scripting Languages Examples, Bash, Sh, Python, Powershell, MSDOS, PHP, Tcl, Perl”

  1. #!/usr/bin/python3

    printf(“Hello World”) #?

    its just ‘print()’ not ‘printf()’ printf is for C language.

    Reply

Leave a Comment