Last active
January 12, 2017 23:18
-
-
Save angrychimp/592544a8e7fb2bfbc40918dec281f871 to your computer and use it in GitHub Desktop.
Using random variables in a subshell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # As an example, how to randomly distribute files to a collection of folders | |
| find source/ -type f -print0 | \ | |
| xargs -r0 -P 10 -I{} sh -c " | |
| folders=($(ls targets/)) | |
| mv --target-directory=targets/\${folders[\$(expr \$RANDOM % \${#folders[@]})]}/ | |
| " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment