2013-11-06

How to tar subdirs

After having finished my Phd Thesis, I needed to archive more than 1 Tb on our Tape archive. To make this manageable, I decided to split the data according to subdirectory. Here is a small snippet to automate this:
# This lists all subdirectories (-p adds trailing slashes to directories)
ls -p | grep "/"
# This is how you tar each subdirectory separately and move it away
for dir in $(ls -p | grep "/")
do
echo ${dir}
tar cvzf ${dir}.tar.gz ${dir} && mv ${dir}.tar.gz /some/archive
done

Keine Kommentare:

Kommentar veröffentlichen