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
- Fibonacci Series in Bash
- Simple Calculator in Bash
- Average of given numbers 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 program to check if the Number is a Prime or not
- Useful and time saving bash commands in Linux
- Bash shell script to find sum of digits
- Bash shell script to swap two numbers
- Write a bash script to print a particular line from a file
- 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 firstname.lastname@example.org. 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.