1 2 3 4 5 6 7 8 9 10 11 12 13 14
#!/bin/bash unlinks=( $(grep -L '\[.*\]\[.*\]' *) ) total_things=$(ls | wc -l) if [[ -n $1 && $1 == "-l" ]]; then echo ${unlinks[@]} | tr ' ' '\n' else echo "${unlinks[$((RANDOM %= $((${#unlinks[@]}))))]}" echo "(${#unlinks[@]} of $total_things still to link.)" fi #[no link][]