Menu Bar

Friday, June 10, 2016

Sleep Sorting using Bash Script

#!/bin/bash

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

while [ -n "$1" ]
do
 f "$1" &  shift 
done
wait
Source: https://gist.github.com/mmazer/3773811

To test:

$ ./sleep_sorting.sh 3 1 1 5 6 2
1
1
2
3
5
6

No comments:

Post a Comment