Created
June 25, 2014 14:59
-
-
Save yulgit1/833c392a4d75740c8060 to your computer and use it in GitHub Desktop.
akubra redist
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
#!/bin/bash | |
#note this program requires the setting of three variables: | |
# 1) the original akubra directory | |
# 2) the destination akubra directory | |
# 3) and awkcmd representing the hash structure | |
time_start=$(date) | |
orig_dir='/usr/local/fed362/data/objectStore' | |
#orig_dir='/usr/local/fed362/data/datastreamStore' | |
dest_dir='/usr/local/fed362/data/objectStore_dest2' | |
#dest_dir='/usr/local/fed362/data/datastreamStore_dest' | |
file_count = 0 | |
dir_count = 0 | |
## | |
##/## = 16,777,216 | |
##/##/# = 268,435,456 | |
#awkcmd='{ print substr($0,1,2); }' | |
awkcmd='{ print substr($0,1,2) "/" substr($0,3,2); }' | |
#awkcmd='{ print substr($0,1,2) "/" substr($0,3,2) "/" substr($0,5,1); }' | |
echo "Origin dir:" $orig_dir | |
echo "destination dir:" $dest_dir | |
function directory_recurse() { | |
for ff in "$1"/* | |
do | |
if [ -d "$ff" ] | |
then | |
dir_count=$[$dir_count +1] | |
#echo "directory $ff" | |
directory_recurse $ff | |
elif [ -f "$ff" ] | |
then | |
file_count=$[$file_count +1] | |
#echo "oldfilepath $ff" | |
filename=$(basename $ff) | |
path=`echo -n $filename | sed 's/%3A/:/g' | sed -e 's=%2F=/=g' | md5sum | awk "$awkcmd"` | |
fullpath=$dest_dir/$path/$filename | |
mkdir -p $dest_dir/$path | |
echo "cp $ff $dest_dir/$path/$filename" | |
cp $ff $dest_dir/$path/$filename | |
fi | |
done | |
} | |
for f in $orig_dir | |
do | |
if [ -d "$f" ] | |
then | |
directory_recurse $f | |
fi | |
done | |
echo "---" | |
echo "file count:" $file_count | |
echo "dir count:" $dir_count | |
time_end=$(date) | |
echo "start:" $time_start | |
echo "end:" $time_end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment