Showing posts with label bash genius sleep sort. Show all posts
Showing posts with label bash genius sleep sort. Show all posts

Saturday, November 19, 2022

Bash Sleep Sort

#!/bin/bash

function f() {
sleep "$1"
echo "$1"

}
while [ -n "$1" ]
do
f "$1" &
shift
done
wait

 Run the script.

./file.sh 6 1 3 7 8 4 2

Output :

It will sort the numbers and print them after 'printed number' seconds.

ex- 7 will be printed after 7 seconds.