Archive Directories
#!/bin/bash
# Loop through all directories within the current directory# tar and gzip all files into a single tarball file
for dir in *
do
if [ -d "${dir}" ] then
echo "archiving ${dir} with tar -zcvf"
echo "tar -zcvf \"${dir}\".tar.gz \"${dir}\""
dest=`echo ${dir} | tr -t '[ ]' '[_]'`
echo "dest is now ${dest}"
tar -zcvf "${dest}".tar.gz "${dir}"
rm -rf "${dir}"
fi
done
No comments:
Post a Comment