Skip to content

Instantly share code, notes, and snippets.

@filesmuggler
Last active January 7, 2021 15:03
Show Gist options
  • Save filesmuggler/7fbb66e01a52523665ecabd30b65b0d1 to your computer and use it in GitHub Desktop.
Save filesmuggler/7fbb66e01a52523665ecabd30b65b0d1 to your computer and use it in GitHub Desktop.
Download chosen directory from git repository instead of cloning whole repo
#!/bin/bash
: '
Downloads data from given github folder
Autor: Krzysztof Stezala <krzysztof.stezala at student.put.poznan.pl>
Version: 0.1
License: MIT
Example use:
bash download_dir_from_github.sh https://github.com/CSSEGISandData/COVID-19/tree/master/csse_covid_19_data/csse_covid_19_time_series
'
REPO_LINK=$1
DIR="data"
TRUNK="trunk"
if [ -d "$DIR" ]; then
# Take action if $DIR exists. #
echo "Directory ${DIR} exists."
echo "Updating ${DIR} directory.."
svn export --force "${REPO_LINK/"tree/master"/$TRUNK}" ${DIR}
else
echo "Creating ${DIR} directory..."
mkdir data
echo "Copying data to ${DIR} directory.."
svn export --force "${REPO_LINK/"tree/master"/$TRUNK}" ${DIR}
fi
@filesmuggler
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment