On 1/23/11 2:51 PM, Johan Martinez wrote:
>
> 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?

No, tar only generates a single output stream.

> 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.

What's not elegant about a script that does exactly what you want?

> Also, it may not scale as number of subdirectories change. Any other solutions
> or tips for doing this will be really helpful.

Decide how you want to specify the list (in the script, in something the script 
can read, or a wildcard name expansion) and use a 'for' shell loop with the 
list 
that also expands the name into the output filename.

-- 
   Les Mikesell
    lesmikes...@gmail.com
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos

Reply via email to