Advertisement
plirof2

bash select random file from folder

Apr 26th, 2023
1,367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.18 KB | None | 0 0
  1. #BASH select a random file from a folder
  2. MY_FOLDER="/tmp/myfolder/"
  3.  
  4. myfile=$( find "$MY_FOLDER" -type f -print0 | shuf -z -n 1 )
  5.  
  6. echo RANDOM FILE SELECTED
  7. echo "$myfile"
  8.  
  9.  
  10.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement