Reputation: 105
I have a huge directory containing thousands of files. If I create a single tar.bz2 with all of them, it generates a cumbersome 8GB file, so when I need to bzcat it, it takes quite long.
Is there any way to create multiple tar files containing, say, a thousand files each?
Maybe I'm wrong, but I think the split command wouldn't really work because it may split a single file in two parts, one of each in a different tarball.
Any suggestion would be REALLY welcome.
Thanks in advance.
Upvotes: 2
Views: 34
Reputation: 4191
i=0;
j=0;
for f in *
do
j=$((j+1))
if [ $((($j) % 1000)) == 0 ]
then
i=$((i+1))
fi
tar -rf $i.tar $f
done
Upvotes: 1