Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- # Don't ask me why I wrote this.
- # Suffice to say I'm a total sperg.
- # Setup
- mkdir subset_dir
- ls -1 > list.txt
- # Create list of 30 random files
- for ((i=0; $i<30; i++)); do
- declare -i length=$(wc -l list.txt | cut -d ' ' -f 1)
- declare -i r=$RANDOM%$length+1
- sed -n "${r}p" list.txt >> sublist.txt
- done
- # Remove dublicates
- cat sublist.txt | sort | uniq > subsublist.txt
- let length=$(wc -l subsublist.txt | cut -d ' ' -f 1)
- # Copy files from list
- for ((i=1; $i<=$length; i++)); do
- file=$(sed -n "${i}p" subsublist.txt)
- cp $file subset_dir
- done
- # Cleanup
- rm list.txt sublist.txt subsublist.txt
- unset i length file
Add Comment
Please, Sign In to add comment