If you find this guide helpful or have more information or additional ideas, you can give me a feedback by posting a comment. That is it with extracting tar files to a specific directory and also extracting specific files from a tar file. /./path/to/otherdirectory filepath2 Each successive -C changes the current directory for everything that follows, so directories have to be specified relative to the previous directory. Img 05: Extract Specific Files From Tar Archive Summary 1 Answer Sorted by: 2 You can change directories as many times as necessary: tar xvzf C /path/to/directory filepath1 -C. What are tarballs Theyre a group of files bundled together in a single file. # 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/ 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 tgz archive files, also called 'tarballs. The tar command on Linux is often used to create. To extract an archive to the current folder, run the command tar -xzvf (archive file)'. Img 02: Extract Tar Files to Specific Directory Example 2: Extract. Run 'tar -czvf (archive name).tar.gz (pathtofile) in the Terminal to compress a file or folder. # tar -xvf articles.tar -directory /tmp/my_articles/ Let me also use the -directory option instead of -c for the example above. In the above example I used the -v option to monitor the progress of the tar extraction. 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. Example 1: Extracting tar Files to a Specific Directory I would advise to unpack the files from the end of the archiveĪnd delete them in reverse order of the archive.Let us now look at some examples below. The same command can be used to extract tar archives compressed with other algorithms such as. Repeat the operation five (or six) times. To extract a tar.gz file, use the -extract ( -x) option and specify the archive file name after the f option: tar -xf The tar command will auto-detect compression type and will extract the archive. In this case, you might unpack 20 GB of files and then delete them Unpack in order to create a a new instance of the archive. You can only use `-delete' on an archive if the archive device allows you to write to any point on the media, such as a disk because of this, it does not work on magnetic tapes.Īs this requires the media to support random reads/writes, this might withĪ bit of luck mean that -delete is done in-place without doing The documentation for the tar option -delete has this interesting text :
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |