Created
July 30, 2011 16:31
-
-
Save matiskay/1115710 to your computer and use it in GitHub Desktop.
Zip files that have the same name
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
#!/bin/bash | |
# Reference | |
# http://stackoverflow.com/questions/965053/extract-filename-and-extension-in-bash | |
# Description | |
# If you have these files | |
# a.x a.y a.z b.x b.y c.z | |
# The script zip them to | |
# a.zip b.zip c.zip | |
function getFilenames() { | |
for file in $(ls); do | |
# Get the filename | |
filename=${file%.*} | |
echo $filename | |
done | |
} | |
filename=$(getFilenames | uniq) | |
for x in $filename; do | |
tar cvfz $x.tar.gz $x.* | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment