Only output the first 5 entries of the result

shuf

shuf --head-count={{5}} {{filename}}

click the source code to copy install shuf on any operating system with command-not-found.com