Extract one file using tar

  • I needed to extract a single file from a tarball or tar file. The following line is what I used to complete this.

sudo tar -C subdir_1/ -zxvf my_etc.tar etc/aliases

The break down:

  • tar – the command
  • -C – tells the command that you want to put it someplace else. In this case a existing directory called “subdir_1”.
  • -zxvf – tells the command to z (unzip, because this was compressed when the tar was created), x (extract), v(verbose, repeat back what process was performed), f(file, the object is will be working with)
  • my_etc.tar – the compressed tarball I am pulling the file from
  • etc/aliases – the file “aliases” I want to extract is in the “etc/” directory.

0 Comments

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>