tar -zxvf /path/to/ \ # The archive to extract My understanding is that -C specifies the extraction location. In order to extract these two directories to /home/bleistift2/tmp (in the file system, not the archive), I issue the following command. I’ve got a tar archive /path/to/ that contains, among others, the directories home/bleistift2/stuff and home/bleistift2/more_stuff. Tar -xf tarball.tar file1 file2 -C destination If I do not specify the files to be extracted (so If I execute the script, destination is empty and ls. Ls destination # Should contain file1 and file 2 Tar -xf tarball.tar file1 file2 -C destination # Extract two files from Mkdir -p destination # Create destination directory Tar -tf tarball.tar # Should contain files 1–3 Rm file1 file2 file3 # Remove source files Tar -cf tarball.tar file1 file2 file3 # Create the archive Touch file1 file2 file3 # Create files to be archived Set -e # Abort if any of these commands fails Store (or execute) it in an empty directory #!/bin/bash -x Here’s a bash script to show the behaviour. Is this a bug or is my understanding of -C wrong? Minimal Working Example The files are extracted in my current working directory. However, if I try to specify files to be extracted from the tarball, the -C option appears to be ignored. I’ve got a tarball tarball.tar I want to extract to destination, a directory that is different from my current working directory, so I use tar’s -C option, which does what I want. ![]() The old information is below in order to not invalidate answers and comments that were based on it. If you are looking for additional helpful solutions, you might want to check out this How to Open Files as Root article.In light of new information I’ve rephrased the question. Hopefully this section has helped you decompress, unpack and extract those compressed tar and tar gz files you downloaded from the internet. A few simple commands are all it takes to untar, unzip or extract tar gz files. Or to extract to another directory, type the following, changing /myfolder to the path you want to extract to: tar -C /myfolder -zxvf file_ Note that this process also works to decompress and extract the contents of a. (replacing file_ with the actual name of your file), use the following command:
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |