![]() Gzip's decompressed with tar xfz Īnd bzip2's decompressed with tar xfvj 2 The flag for that is J so can be extracted into ~/stuff/new/ with: Look at the files file extension and identify it's compression by it's name. Most archives you encounter will be compressed with some kind of compression. Tar xf archive.tar -C ~/stuff/new/software Using -C is completely optional, files are simply extracted to the folder you are in if you omit it. Using it is as simple as adding -C folder/. Tar has a handy -C flag to extract files into a specific folder. An uncompressed archive will obviously not need a compression flag. lz files/*.txt stuff/*.jpg HOWTO extract tar archivesĮxtraction of tar archives is done by running tar with the e xtract flag, the file flag since we are using files not a tape drive like it's the 1980s and a flag for the compression that was used - followed by the filename. ![]() You have to add the entire -switch if you want to use a "special" algorithm without its own short-hand flag and you have to use the -f flag last and in this case it needs to have the - in front to indicate it's a flag.įor example, creating an lzip archive is done with: gz files/*.txt stuff/*.jpg Non-shorthand compression algorithms Similarly, creating a gzip archive, where the swich is z and the extension is. So we add that to the above example and get: That would be j and the extension bz2 for bzip2. This is done by adding the right switch and the right extension to the archive you create. You will want to (ab)use some kind of compression for your archive. Tar cfv container.tar files/*.txt stuff/*.jpg You can add the fine v flag for verbose output of what is going on: Tar cf container.tar files/*.txt stuff/*.jpg This will create a pure container with the contents of files/*.txt and stuff/*.jpg without doing any kind of compression: There is no difference between tar cf and tar -cf and tar -c -f. ![]() While the manual and many examples refer to the switches with a - and the - can be used it's actually not needed. -f use archive file or device F (default "-", meaning stdin/stdout).Pure tar archives are created with the cf switch. It does not have its own short-hand switch, though it's gaining popularity so it could get one. ![]()
0 Comments
Leave a Reply. |