Skip to content

Instantly share code, notes, and snippets.

@myfavouritekk
Created October 6, 2014 08:52
Show Gist options
  • Save myfavouritekk/7d4e1ae127a46770dea6 to your computer and use it in GitHub Desktop.
Save myfavouritekk/7d4e1ae127a46770dea6 to your computer and use it in GitHub Desktop.
Random select files in bash
files=(/my/dir/*)
printf "%s\n" "${files[RANDOM % ${#files[@]}]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment