Skip to content

Instantly share code, notes, and snippets.

@cwvhogue
Created October 21, 2013 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cwvhogue/7088988 to your computer and use it in GitHub Desktop.
Save cwvhogue/7088988 to your computer and use it in GitHub Desktop.
Draft - retrieve a Manta Directory Hierarchy and File content on a Unix/Linux platform. Works with spaces in path names.
# Phase 1 Retrieves directories, creates hierarcy from current working directory.
mfind -t d ~~/stor/winfoo | sed "s,/$MANTA_USER/stor/,," | xargs -I {} mkdir -p "{}"
# This retrieves object paths, splits into download file and target local directory file
# Phase 2 retrieves objects, splits into source/target directories, calls mget
mfind -t o ~~/stor/winfoo | tee dnldfiles.txt | sed -e "s,/$MANTA_USER/stor/,," | xargs -I {} dirname "{}" > dnlddirs.txt
# the dnlddirs.txt file can be prepended with a target directory or windows-ified
cat dnldfiles.txt | xargs -I {} basename "{}" > dnldnames.txt
paste -d '/' dnlddirs.txt dnldnames.txt > targets.txt
paste -d '"' dnldfiles.txt targets.txt > dnldsets.txt
# put quotation marks at front and end of each line... stick in -o .. run mget
sed -e 's/\"/\" -o \"/g' -e 's/$/"/' -e 's/^/\"/' dnldsets.txt | xargs mget
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment