List/Grid Shell Scripting Subscribe RSS feed of category Shell Scripting
How to create a Terminal Clock using Shell Script
date command displays current date and time to the Terminal and we can use this command to recursively display time every second on Terminal which will look like a Terminal Clock. In this tutorial, I will show you how to create a Shell Script which will make the terminal to show system time every second like a clock. Default output of date command prints result in the format shown in…
How to find Average of Numbers provided through Command Line using Shell Script
In this tutorial, I will show you how to use Shell Script to find Average of any number of arguments (numbers) provided through Command Line. The script will find show an error if no argument is provided, otherwise it will find Average of numbers provided and prints its output on the Terminal. Algorithm: Check if the numbers of arguments supplied are equal to 0 or not. If yes, print error message…
How to check for leap year in Shell Script
In this tutorial, I will show you a simple shell script to check whether a given number provided through command line denotes a leap year or not using shell script. Algorithm is fairly simple Check whether the number of command line arguments are equal to 1 or not If not equal to 1, then print an error message and exit, otherwise proceed to next step. Store the value of the…
How To reverse the digits of a number using Shell Scripting
In this tutorial, I will share a simple script to reverse a number provided through command line in Unix/Linux Operating System. The script will print the reversed digits of provided number and if no number or more than one numbers are provided, then it will print an error. Algorithm is fairly simple : Let n be the given number. Set rev and rem equals to 0. Find last digit of…
How to add Open With Gedit to the right click menu in Ubuntu
Nautilus Scripts in Ubuntu provides the functionality for file browser to do just about anything. These scripts are invoked by selecting a file or group of files, and right-clicking with the mouse, to bring up a context menu. One of the options in this right click context menu is the ‘Scripts‘ sub menu, which allows you to select a script to invoke on the selected files. In this tutorial, I will…
How To Find Sum of Sum of digits of a number using Shell Scripting
In this imple tutorial, I will be using while loop to print the sum of digits of a number which is provided through command line. You can also download the sample script using the link provided at the bottom of the page. Instructions: First of all we will define the Shell program we want to use to run our script using the following command #!/bin/bash Now we will check whether…
How To find out Biggest number among the three provided numbers through command line using Shell Scripting
In this tutorial, I will show you how can we find out the biggest number among three numbers which are provided through command line while running the script/program. Instructions: First of all, we will define the Shell which will execute our program with the following command. #!/bin/bash Now we will check whether the number of arguments passed are equal to 3 or not, if not we will print error message…
How To Determine Whether you have 32 bit or 64 bit Linux installed in your machine
In this tutorial, I will share two Shell commands which you can use to find out whether you have 32 bit or 64 bit Linux Operating System installed in your machine. Instructions: Using uname command uname command is used to print certain information about your system. By using the option -m with uname, will print only the machine hardware name from which you can find out whether the OS is…
How To Find Sum of Two Numbers which are supplied as Command Line Arguments
In this tutorial, I will show you a quick example to find sum of two numbers using a script in Linux Shell which are supplied as Command Line arguments while running the script. If number of arguments are not equal to 2, then the script will print an error message. Instructions: First of all I will set the shell which will used to run the script using the following command,…