Skip to content

Instantly share code, notes, and snippets.

@hsuh
Last active August 29, 2015 14:15
Show Gist options
  • Save hsuh/069becb4a3482968cc19 to your computer and use it in GitHub Desktop.
Save hsuh/069becb4a3482968cc19 to your computer and use it in GitHub Desktop.
copying files (like a boss)
#!bin/bash
#set -xv
cpSource='your/root/folderxxx'
cpDest='your/root/folderxxx'
verbose=false
case "$1" in
-v)
verbose=true;;
esac
function verbosity0() {
if [ "$verbose" = false ]; then
sed "s/^.*folderxxx\///";
else
cat;
fi
}
function verbosity1() {
#trim down cp's verbose print out
sed "s/^.\(.*\). ->.*/\1/" | verbosity0 ;
}
function copy_files() {
echo '***copying components folders and files***'
cp -rav $cpSource/components/* $cpDest/components | verbosity1
echo '=========================Done==========================='
echo '***copying filters files***'
cp -rav $cpSource/filters/* $cpDest/filters | verbosity1
echo '=========================Done==========================='
echo '***copying reports***'
cp -rav $cpSource/reports/* $cpDest/reports | verbosity1
echo '=========================Done==========================='
echo '***copying templates***'
cp -rav $cpSource/templates/* $cpDest/templates | verbosity1
echo '=========================Done==========================='
echo '***copying util js files***'
cp -rav $cpSource/util/* $cpDest/util | verbosity1
echo '=========================Done==========================='
echo '***copying files from root folder***'
find $cpSource -maxdepth 1\
-not -iname karma* \
-not -iname gruntfile.js \
-not -iname package.json \
-not -iname .vimrc \
-not -iname workbench-load-resources.js \
-not -iname workbench-main.js \
-type f \
-exec \
cp -a {} $cpDest \; -print | verbosity0;
echo '=========================Done==========================='
echo '***preparing workbench-load-resources***'
DEBUG_FUNC=loadCapacityPlannerComponents
JS_VERSION=1.0.281
sed "s/\(${DEBUG_FUNC}Debug\)/\1-/;\
s/\($DEBUG_FUNC\) /\1Debug /;\
s/\($DEBUG_FUNC\)Debug-/\1/;\
s/%VERSION%/$JS_VERSION/g" ${cpSource}/workbench-load-resources.js > ${cpDest}/workbench-load-resources.js
echo '=========================Done==========================='
#find $cpSource/components -maxdepth 1 -type f \
# -exec \
# cp -a {} $cpDest/components \; -print | verbosity0;
}
copy_files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment