This repository has been archived on 2024-03-04. You can view files and clone it, but cannot push or open issues or pull requests.
linux/.config/bash/module/Random.sh

11 lines
201 B
Bash
Raw Normal View History

2023-12-19 16:18:57 +03:00
# 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]}
}