Last active
December 14, 2017 11:18
-
-
Save dzungtran/ed05134f89f52c6d1e4a39b006466756 to your computer and use it in GitHub Desktop.
[Updating] Awesome bash commands will help to save time for your life
This file contains hidden or 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
# USER GUIDE: | |
# Do not run this script directly | |
# Compress multiple folders, each into its own zip archive | |
# BEGIN | |
for i in */; do zip -r "${i%/}.zip" "$i"; done | |
# OR | |
for i in * | |
do | |
[ -d "$i" ] && zip -r "$i.zip" "$i" | |
done | |
# END | |
# Find all file in current folder matched with pattern and remove them. | |
# BEGIN | |
find . -name "FILE-TO-FIND" -exec rm -rf {} \; | |
# OR | |
find . -type f -name "FILE-TO-FIND" -exec rm -f {} \; | |
# EXPLAIN: | |
# -name "FILE-TO-FIND" : File pattern. | |
# -exec rm -rf {} \; : Delete all files matched by file pattern. | |
# -type f : Only match files and do not include directory names. | |
# END | |
# Find all file extension | |
# BEGIN | |
find . -type f -name '*.*' | sed 's|.*\.||' | sort -u | |
# END | |
# Delete all empty folder | |
# BEGIN | |
find . -type d -empty -delete | |
# END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment