Last active
December 10, 2017 17:21
-
-
Save schlueter/ae4c9f5510110c5358db074779df3b3c to your computer and use it in GitHub Desktop.
Time use of xargs and awk to rename a set of directories
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
#!/usr/bin/env bash | |
set -e | |
((DEBUG)) && set -x | |
TIMES=100 | |
WORDS=100 | |
rm -rf $(<head-words) | |
rm -rf $(<tail-words) | |
uniq -i /usr/share/dict/words > uniq-words | |
tail -$WORDS uniq-words > tail-words | |
head -$WORDS uniq-words > head-words | |
paste -d' ' head-words tail-words > paired-words | |
for c in 'cat paired-words | xargs -n2 mv' \ | |
'< paired-words xargs -n2 mv' \ | |
"awk '{system(\"mv \" \$1 \" \" \$2)}' paired-words" | |
do | |
echo "Executing $TIMES trials of \`$c\`" | |
time for n in $(seq 1 $TIMES) | |
do | |
mkdir $(<head-words) | |
sh -c "$c" | |
rmdir $(<tail-words) | |
done | |
echo | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment