mkdir-sort
sorting algorithm using mkdir
Example
$ mkdir wkdir
$ cd wkdir
$ ./mkdirsort.sh 9 2 7 4 6
$ rm -rf g/
Posted on August 29, 2018
A little sorting algorithm I made just for fun.
#!/bin/bash
function f() {
echo $(eval printf 'g/%.0s' {1.."$1"})"$1" | xargs mkdir -p
}
while [ -n "$1" ]
do
f "$1"
shift
done
find . -type d | sed 's#.*/##' | grep -v g
#./mkdirsort.sh 9 2 7 4 6
It's like a "b-tree sort" using the FS
sorting algorithm using mkdir
$ mkdir wkdir
$ cd wkdir
$ ./mkdirsort.sh 9 2 7 4 6
$ rm -rf g/
Posted on August 29, 2018
Sign up to receive the latest update from our blog.