Skip to content

Instantly share code, notes, and snippets.

@mherwig
Created February 13, 2014 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mherwig/8975010 to your computer and use it in GitHub Desktop.
Save mherwig/8975010 to your computer and use it in GitHub Desktop.
Copy a folder to another using tar. This way you can easily (one-way) synchronize whole folders and exclude files e.g. .metadata
#!/bin/bash
#
# Author: Mike Herwig
# Description:
# Copy a folder to another using tar.
# This way you can easily (one-way) synchronize whole folders and exclude files e.g. .metadata
#
# Usage:
# tarcp ~/directory1" "~/directory2
if [ $# -lt 2 ]; then
echo "Usage:"
echo "$0 source target"
exit 1
fi
SOURCE=$1
TARGET=$2
tar -cf - -C "$SOURCE" --exclude ".metadata" . | (cd "$TARGET"; tar -xf - )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment