From owner-freebsd-questions@FreeBSD.ORG Sun Feb 8 17:57:27 2015 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id CB7A2A37 for ; Sun, 8 Feb 2015 17:57:27 +0000 (UTC) Received: from be-well.ilk.org (be-well.ilk.org [23.30.133.173]) by mx1.freebsd.org (Postfix) with ESMTP id A207F641 for ; Sun, 8 Feb 2015 17:57:27 +0000 (UTC) Received: from lowell-desk.lan (lowell-desk.lan [172.30.250.41]) by be-well.ilk.org (Postfix) with ESMTP id 7C8CE33C1D; Sun, 8 Feb 2015 12:57:21 -0500 (EST) Received: by lowell-desk.lan (Postfix, from userid 1147) id B68C83980F; Sun, 8 Feb 2015 12:57:20 -0500 (EST) From: Lowell Gilbert To: Manish Jain Subject: Re: why does tar archive directory differently based on command line? References: Reply-To: freebsd-questions@freebsd.org Date: Sun, 08 Feb 2015 12:57:20 -0500 In-Reply-To: (Manish Jain's message of "Sun, 8 Feb 2015 13:23:12 +0530") Message-ID: <44bnl4qoan.fsf@lowell-desk.lan> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain Cc: freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Feb 2015 17:57:27 -0000 Manish Jain writes: > I am having problems trying to understand why does tar archive > differently with the following 2 commands, presuming xyz is a > sub-directory : > > tar -c -f - ./xyz | gzip > xyz.tar.gz//xyz nested one level under . and .. > tar -c -f - xyz | gzip > xyz.tar.gz//no . or .. > > With the first invocation, I get a top-level nesting that just has . and .. > With the second, I get a top-level nesting that has xyz, which is much > preferable Right. tar(1) stores the path to the file. This is essential functionality, so if you want a particular path stored, you provide that path in the way you invoke tar in the first place. > The first invocation leads to an absurdity that you have to cd into > . (sounds recursively impossible) to actually get to xyz It's neither absurd nor recursively impossible (whatever that means). If you were planning to extract the tar file from one level higher up the destination tree, it would be exactly what you would want. Perhaps you would be happier with a GUI application for creating your tar files. There are many fine choices, and you probably have one (or more) already installed on your system.