Re: tar-ing subdirectories separately

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Hi,

> I want to backup a directory using tar, but want separate tarballs for
> each subdirectory. For example: 
> # ls dir1
> subdir1 subdir2 subdir3
> 
> 
> Will it possible to do it using only tar command? Or will I need
> another separate piece of logic/control? I thought of writing a shell
> script with three tar commands for each subdirectory, but that's not
> elegant way of doing it. Also, it may not scale as number of
> subdirectories change. Any other solutions or tips for doing this will
> be really helpful. 
You can try something like :
find /dir1 -type d -print -maxdepth 0 | while read DIR ; do tar cfv
$DIR.tar $DIR/; done

not tested, just off the top of my head and it's late, so if it breaks,
you can keep and be happy with all the pieces ;)

	Regards,

	Michel




_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos


[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux