Created
May 10, 2020 13:09
-
-
Save merong/58fe9a998022d12a465374daefd4c66f to your computer and use it in GitHub Desktop.
bash script build file with exclude files
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
#!/usr/bash | |
dir=$(cd -P -- "$(dirname -- "$0")" && pwd -P) | |
BASE_PATH=${dir} | |
BUILD_DIR=${BASE_PATH}/build | |
TEMP_DIR=${BASE_PATH}/temp | |
mkdir -p ${TEMP_DIR} | |
exclude_files=( | |
".gitignore" | |
".idea" | |
"build" | |
"temp" | |
) | |
### exclude_files check | |
for fullpath in $(ls -d ${dir}/*); do | |
filename="$(basename -- $fullpath)" | |
#exclue 대상 제외 | |
(for e in "${exclude_files[@]}"; do [[ "$e" == ${filename} ]] && exit 0; done; exit 1) && continue; | |
if [[ -d "${BASE_PATH}/${filename}" ]]; then | |
echo "${filename} is directory." | |
cp -r ${BASE_PATH}/${filename} ${TEMP_DIR} | |
else | |
echo "${filename} is file." | |
cp ${BASE_PATH}/${filename} ${TEMP_DIR} | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment