Re: tar-ing subdirectories separately

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



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
    lesmikesell@xxxxxxxxx
_______________________________________________
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