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

Re: untarring tar file into specific directory



Darren Wyn Rees <merlin@netlink.co.uk> writes:
> What option do I give tar to untar a file into a specific location ?
> 
> I've backed up /var; re-formatted the partition, and now I want to
> untar things back to /var.  I've gone through the manual, but can't
> find the right option. (I need something like unzip's '-d exdir'
> option).

A couple of options...if you want to be maximally compatible with
various Unices, a pipeline like

  (cd /var; gzip -cd var-backup.tar.gz | tar xf -)

is common.  Using GNU tar (e.g. the one in Debian, and most other
GNU/Linux distributions), you can use the -C option:

  tar -C /var -xzf var-backup.tar.gz

-- 
David Maze         dmaze@debian.org      http://people.debian.org/~dmaze/
"Theoretical politics is interesting.  Politicking should be illegal."
	-- Abra Mitchell



Reply to: