11 lines
201 B
Bash
11 lines
201 B
Bash
|
# Picks a random file or directory.
|
||
|
function random_file() {
|
||
|
local IFS=$'\n'
|
||
|
local dirs=($(ls))
|
||
|
local total=${#dirs[@]}
|
||
|
((total--))
|
||
|
local index=$(shuf -i 0-${total} -n 1)
|
||
|
|
||
|
echo ${dirs[$index]}
|
||
|
}
|