About 934,000 results
Open links in new tab
  1. Sorting an array in Bash using Bubble sort - GeeksforGeeks

    Nov 25, 2021 · Given an array arr sort the array in ascending order using bash scripting. Examples: Approach : For sorting the array bubble sort is the simplest technique. Bubble sort …

  2. How to sort an array in Bash - Stack Overflow

    Jul 9, 2015 · If you don't need to handle special shell characters in the array elements: array=(a c b f 3 5) sorted=($(printf '%s\n' "${array[@]}"|sort)) With bash you'll need an external sorting …

  3. How to sort an array in ascending or descending order in a shell script ...

    In shell scripting, sorting arrays in ascending or descending order is a common task that can be achieved using various methods. Here, we'll explore two popular approaches: using the built-in …

  4. Bash Sort Array: Quick Guide to Organizing Elements

    One of the simplest ways to sort an array in Bash is by utilizing the `sort` command. This command processes the input elements and outputs them in a sorted order. Example Code: …

  5. How to Sort Array in Bash - Delft Stack

    Feb 12, 2024 · This demonstration highlights the sort command’s utility in Bash for array sorting, providing an efficient and straightforward solution suitable for both newcomers and …

  6. How to Sort Bash Arrays | Baeldung on Linux

    Mar 18, 2024 · In this tutorial, we’ll learn how to sort arrays in Bash. We’ll begin by sorting an array of integers and floats. Then, we’ll move on to sort strings. Finally, we’ll discuss how to …

  7. arrays - sorting in shell script - Stack Overflow

    Oct 23, 2015 · First split the array elements into lines (most *nix programs work with lines only): for el in "${arr[@]}" do echo "$el" done Then sort the lines: for el in "${arr[@]}" do echo "$el" …

  8. Ascending and Descending order using shell script - OneCompiler

    #!/bin/bash echo "Enter numbers separated by space:" read -a numbers echo "Ascending order:" echo "${numbers[@]}" | tr ' ' '\n' | sort -n echo "Descending order:" echo "${numbers[@]}" | tr ' ' …

  9. Array Basics Shell Scripting | Set 2 (Using Loops)

    Apr 18, 2023 · Prerequisite: Bubble Sort Given an array arr sort the array in ascending order using bash scripting. Examples: Input : 9 7 2 5 Output : Array in sorted order : 2 5 7 9 …

  10. How to create a function that can sort an array in bash?

    Dec 6, 2015 · To sort array a into array b: would sort the array reliably. Use the -n, -r options to sort to sort numerically or in reverse (or any sort criteria supported by sort). To implement your …

  11. Some results have been removed
Refresh