Find all files with the extension ".php" in the directory "~/path" and its subdirectories, randomly select one of them and save its name to the file "file.txt".
find ~/path -xdev -name "*.php" -print0 | xargs -0 shuf -n 1 -o file.txt