outletvova.blogg.se

Linux untar to a specific directory
Linux untar to a specific directory




linux untar to a specific directory
  1. Linux untar to a specific directory how to#
  2. Linux untar to a specific directory archive#

That is it with extracting tar files to a specific directory and also extracting specific files from a tar file.

Linux untar to a specific directory archive#

Img 05: Extract Specific Files From Tar Archive Summary # tar -xvf etc.tar etc/issue etc/nf etc/mysql/ -C /backup/tar_extracts/ In the next example, I will extract specific files out of a tar file to a specific directory as follows: # mkdir /backup/tar_extracts The tar utility also allows you to define the files that you want to only extract from a. Img 04: Extract tar.bz2 Files to Different Directory Example 4: Extract Only Specific or Selected Files from Tar Archive # tar -jvxf documents.tbz2 -C /tmp/tar.bz2/

linux untar to a specific directory

Now we will be unpacking the documents.tbz2 files to /tmp/tar.bz2/ directory. tbz2 Files to Different DirectoryĪgain repeating that you must create a separate directory before unpacking files: # mkdir -p /tmp/tar.bz2 tgz Files to Different Directory Example 3: Extract tar.bz2. Now we will extract the contents of documents.tgz file to separate /tmp/tgz/ directory. tgz Files to Different Directoryįirst make sure that you create the specific directory that you want to extract into by using: # mkdir -p /tmp/tgz Img 02: Extract Tar Files to Specific Directory Example 2: Extract. # tar -xvf articles.tar -directory /tmp/my_articles/ Let me also use the -directory option instead of -c for the example above.

linux untar to a specific directory

Files can be extracted using the -C flag with the specified folder path. In the above example I used the -v option to monitor the progress of the tar extraction. Tar utility also comes with a feature to extract tar files to a specific directory. Img 01: Extract Tar Files to Different Directory To extract the files in articles.tar to /tmp/my_article, I will run the command bellow: # tar -xvf articles.tar -C /tmp/my_article/ You can include the -p option to the above command so that the command does not complain. Let me start by creating the /tmp/my_article directory using the command below: # mkdir /tmp/my_article Always make sure that the directory into which you want to extract tar file exists. In the first example, I will extract the files in articles.tar to a directory /tmp/my_article. where some directory is the directory into. Example 1: Extracting tar Files to a Specific Directory unzip (version 6.00) can not extract files read from standard input (this is mentioned in the unzip manual, in the 'BUGS' section), so the file will need to be saved locally before extraction: curl -o myfile.zip 'some URL' unzip myfile.zip -d 'some directory' rm -f myfile.zip. The *.tar.bz2 can be untarred like below.Let us now look at some examples below. The bz2 is another popular compression format where tar can be compressed with it. In the following example, we extract the tar.gz file. The tar files can be compressed with the gzip as gz format. PATH is optional and used in the tar file is extracted differently than the current working path.Ī tar file can be untared or extracted with the following command.OPTIONS is used to untar different compressions formats.The tar command has the following syntax which can be used to untar files and folders in different ways. This option must be followed by the name of the tar file. f: File, the name of the tar file we want tar to work with. z: Gzip, use gzip to decompress the tar file. v: Verbose, list the files as they are being extracted.

Linux untar to a specific directory how to#

In the tutorial, we examine how to untar files with different compressions algorithms like gz, bz2 etc. The command line options we used are: -x: Extract, retrieve the files from the tar file. path/to/directory: Absolute path of the target directory. filename.tar: Denotes the tar archive file. directory: Perform the same task as the C flag. Options: Supported options of tar command C: Shows the other particular mentioned directory. The most important function of the tar format is the ability to store multiple files and directories as a single file where it can be easily compressed. The above both syntax contains the following components: tar: Represents the tar utility. The tar format is used with different compression algorithms like gz, bz2, etc. The *.tar is a popular archive format used to compress files in Linux and Unix operating systems.






Linux untar to a specific directory