aboutsummaryrefslogtreecommitdiff
path: root/entries/braxtonhall/wc/fib.sh
blob: 1759dffbf736bbbe2bde2ddd7f478fe953d7e6f7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash

function rec () {

    if [ $2 == "0" ]; then
        :
    elif [ $2 == "1" ]; then
        [ -f "$1/$2" ] || echo "🥵" > "$1/$2"
    else
        [ -d "$1/$2" ] || mkdir "$1/$2"
        rec "$1/$2" $(($2 - 1))
        rec "$1/$2" $(($2 - 2))
    fi
}

if [[ $1 =~ ^[0-9]+$ ]]; then
    rec $(pwd) $1
    find $(pwd)/$1 -type f | wc -l
else
    echo "Please provide a natural number!"
    exit 1
fi