Prerequisite : Bubble Sort
Given an array arr sort the array in ascending order using bash scripting.
Input : 9 7 2 5 Output : Array in sorted order : 2 5 7 9
For sorting the array bubble sort is the simplest technique. Bubble sort works by swapping the adjacent elements if they are in wrong order .
Given array - (9, 7, 2, 5) After first iteration - (7, 2, 5, 9) After second iteration - (2, 5, 7, 9) and so on...
In this way, the array is sorted by placing the greater element at the end of the array .
Array in sorted order : 8 10 12 20 100
- Average of given numbers in Bash
- Simple Calculator in Bash
- Fibonacci Series in Bash
- Programs for printing different patterns in Bash
- Bash program to find A to the power B
- Bash program to check if the Number is a Palindrome
- Bash shell script to find sum of digits
- Bash program to check if the Number is a Prime or not
- Bash Script to get Low Battery Alert in Linux
- Bash shell script to swap two numbers
- Useful and time saving bash commands in Linux
- Write a bash script to print a particular line from a file
- How to Fix Minimal BASH Like Line Editing is Supported GRUB Error In Linux?
- Bash shell script to find out the largest value from given command line arguments
- SORT command in Linux/Unix with examples
- Array Basics in Shell Scripting | Set 1
- Array Basics Shell Scripting | Set 2 (Using Loops)
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : nitin_19520