Bash Useful Examples

A collection of simple Bash scripts.

Getting Started

  1. get a simple output

  2. execute more than one command in a script

  3. a simple but very much interactive script

  4. draw a diamond pattern with dots(.)

  5. read lines from a file using while loop

  6. display a menu for system information

  7. a repeated menu for system information

  8. print a spinner loader

  9. provide you with the output of several colours

  10. convert data either from the file or standard input to lowercase

  11. move up a directory in shell script

  12. list files in a directory

  13. print out the line number of each file in current directory

  14. create unique file/folder automatically with date and time stamp

  15. print ramdom emojis

  16. a simple pomodoro app written in bash


  1. compare two version number


  1. encrypt a file/folder with password

  2. archive a path into a file and encrypt the file

  3. check the weather in a specified location or using the geolocation of the ip address by default.

  4. Get location of an IP address.

System Administration

  1. output a specified directory's size

  2. evaluate the status of a file/directory

  3. report server related information

  4. report if CPU usage exceeds the threshold

  5. check if the disk space crosses the limit

  6. gather information related to server

  7. backup a local file into a remote server

  8. show hardware information for systems Linux

  9. show CPU temperature


  1. perform addition of two numbers

  2. perform subtraction of two numbers

  3. perform multiplication of two numbers

  4. perform division of two numbers

  5. a simple calculator

  6. print table of any number

  7. check if a number input from standard input is odd or even

  8. generate the factorial of a number

  9. check if a provided number is Armstrong or not

  10. check if a number is prime or not

  11. test if a number being entered is a Fibonacci or not

  12. convert Decimal Number to Binary

  13. convert Binary Number back to decimal

  14. convert Decimal Number to Hex

  15. Hex2Decimal: convert Hex number back to Decimal

Image manipulation

  1. create 400px thumbnails from images in a folder

Last updated

Assoc. Prof. Wiroon Sriborrirux, Founder of Advance Innovation Center (AIC) and Bangsaen Design House (BDH), Electrical Engineering Department, Faculty of Engineering, Burapha University