hundred files to tar and untar

David Kelly dkelly at
Mon Nov 10 07:19:32 PST 2008

On Mon, Nov 10, 2008 at 08:10:36AM -0500, chloe K wrote:
> Hi 
>   I have hundred files to tar
>   How can I make tar the file but untar in different folder?
>   eg:
>   tar cvf html.tar /var/web/data/verion/cc.html
>   untar html.tar /var/web/data/root/cc.html
>   Thank you

RTFM. Specifically look at the -C option.

Or you could do it the simple way (note parenthesis, the cd only applies
within the parenthesis, when the command clompletes your shell is back
to the original directory):

(cd /var/web/data/verion/cc.html ; tar -cvf <somewhere>/html.tar * )
(cd /var/web/data/root/cc.html   ; tar -xvf <somewhere>/html.tar   )

The above does not store the path prefix in the tar archive, which is
perhaps the problem you were trying to solve?

David Kelly N4HHE, dkelly at
Whom computers would destroy, they must first drive mad.

More information about the freebsd-questions mailing list