Last active
December 31, 2015 05:49
-
-
Save e3krisztian/7943250 to your computer and use it in GitHub Desktop.
zip up files not yet added to git (they should be data files or other residue)
This file contains 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 | |
# requires sponge from Debian(?) package moreutils | |
set -x | |
project=$(basename $(pwd)) | |
date=$(date +%Y%m%d) | |
zipfile=${project}-${USER}-data-${date}.zip | |
zipargs=( | |
--suffixes .gz:.bz2:.zip:.rar # these are stored without further compression | |
--names-stdin # read files & directories to add from stdin | |
--recurse-paths # add contents of directories, too | |
--symlinks # store them | |
--test # test output after creating | |
--move # remove files after zip file created & tested | |
) | |
git status --porcelain | | |
grep '^[?][?] ' | # keep only unknown files | |
sed 's/^?? //' | # (remove flags) | |
sponge | # paranoia: prevent zip temporary file to be listed | |
zip ${zipfile} "${zipargs[@]}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment