Skip to content

Instantly share code, notes, and snippets.

@msudgh
Last active June 7, 2018 07:18
Show Gist options
  • Save msudgh/bbbc204c0f3a816536926ec19a392e5e to your computer and use it in GitHub Desktop.
Save msudgh/bbbc204c0f3a816536926ec19a392e5e to your computer and use it in GitHub Desktop.
Compress the files and exclude the gitignore file lines
#!/bin/bash
# --------------------------------------------------------------
# [Author] Masoud Ghorbani (@msudgh)
# [Created] June 8, 2017
# [Description] Compress the files and exclude the gitignore file lines
# --------------------------------------------------------------
# Define the source file that represent the files to be exclude
file=.gitignore
# Define zip package's name
filename=/${PWD##/}
# Extract gitignore file's line to exclude from ls command
excludedList=$(while IFS= read -r line; do echo "-I $line"; done < $file)
includeList=$(ls $excludedList -I ${0##*/})
# Zip the ls list
zip -q -r /$filename $includeList
echo "It's Done, ❤ Good Luck."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment