Is there a way to list a set of say, 30 random files from a directory using standard Linux commands? (in zsh)
The top answer described here does not work for me (sort does not recognize the option -R)
|
|
Since you're mentioning zsh:
You can replace |
|||
|
|
|
Try piping the
The |
|||||||||||
|
|
It's quite easy to solve this with a tiny bit of Perl. Select four files at random from the current directory:
For production use though, I would go with an expanded script that doesn't rely on
|
|||||||||||||
|
|
A oneliner using nothing but Zsh:
The same in Bash, where array indices are zero-based:
Note that neither version takes duplicates into account. |
|||||||
|