Categories
Git

Kaggle Github Sync using Shell Script

  1. Create a Github repository
  2. Run “git init” on the local folder
  3. Run “git remote add origin https://github.com/user/repo.git” on the local folder
  4. Create a file shell.sh with the below code on the local folder
  5. Run “bash shell.sh” on the local folder

Shell.sh

for item in $(kaggle kernels list --user USERNAME); do
        if [[ $item == *"USERNAME"* ]]; then
                toreplace=""
                kaggle kernels pull $item -p "${item/USERNAME\/$toreplace}"
        fi
done;
git add .;
git commit -m 'update';
git push -u origin master;

Run Manually

Run “bash shell.sh” on the local folder whenever you make changes to your Kaggle kernels

Crontab

Use crontab to automatically run the script hourly, daily, weekly or monthly