![]() tar.gz files I downloaded wouldn't work because they didn't actually use gzip compression despite the filename. Note that because it's primarily designed as a preprocessor for less, it won't output anything if it doesn't recognise the file type. For files matching the tar.gz extension, we can see that it uses tar tzvf under the hood along with the -force-local option to disable an obscure feature of tar that would otherwise confuse colons in the filename with a command to use a remote tape drive: *.tar.gz|*.tgz|*.tar.z|*.tar.dz) If feeling adventurous, take a peak at vi /usr/bin/lesspipe to see what commands it uses. It is called by the less command ( see Oli's answer) as an input preprocessor if the $LESSOPEN environment variable is set appropriately. rw-rw-r- ubuntu/ubuntu 7 05:32 example/ubuntu.txt rw-rw-r- ubuntu/ubuntu 7 05:32 example/ask.txt $ lesspipe ĭrwxrwxr-x ubuntu/ubuntu 0 05:32 example/ Lesspipe is a shell script installed by default as part of the less package that can list the contents of a tar.gz archive, as well as a range of other common archive file formats. You can then list the contents of any archive: $ list_archive.sh foo.rar foo.tbz foo.zipĠ 8 0% 30-03-15 19:29 -rw-r-r- 00000000 m3b 2.9Ġ 0 0% 30-03-15 19:29 drwxr-xr-x 00000000 m0 2.0Īnd since someone mentioned that lesser editor, naturally, emacs can also do this: Save that script in your PATH and make it executable. Type zip >/dev/null 2>&1 & zip -sf "$file"||Įcho "Unknown extension: '$ext', skipping." Type rar >/dev/null 2>&1 & rar v "$file"|| The secret here is that you need to specify your filename just as it is in the tar. Type tar >/dev/null 2>&1 & tar tf "$file"|| Now, to answer the question, if you want to un-tar one file named 'my-desired-file' from a tar archive named 'my-archive.tgz', and assuming the archive is compressed as most are these days, you'd use a command like this: tar xzvf my-archive.tgz my-desired-file. # have extensions like tar.bz2 or tar.gz etc. With all this in mind, you could write a little script that uses the appropriate command depending on the extension of the file you give to it: #!/usr/bin/env bashįor file in "\n-\nArchive '%s'\n-\n" "$file" That's most of the more popular archive formats. How to create and extract tar files How to untar a tar file in linux Linux tar commandIn this video you will learn how to create and extarct tar archives. Size Packed Ratio Date Time Attr CRC Meth VerĠ 8 0% 30-03-15 19:00 -rw-r-r- 00000000 m3b 2.9Ġ 0 0% 30-03-15 19:00 drwxr-xr-x 00000000 m0 2.0Ġ 0 0% 30-03-15 19:07 drwxr-xr-x 00000000 m0 2.0 Extract a tar file: tar -xvf foo.tar Extract and uncompress a tar.gz file: tar -xvzf Extract and uncompress a tar.bz2 file: tar -xvjf 2 List the Contents of a tar, tar.gz, tar.bz2 Files Sometimes it is needed just to check the contents of a tarball without unpacking it. RAR 4.20 Copyright (c) 1993-2012 Alexander Roshal P7zip Version 9.20 (locale=en_US.utf8,Utf16=on,HugeFiles=on,4 CPUs) Tar/ tar.gz/ tgz/ tar.xz/ tar.bz2/ tbz files $ tar tf foo.tgzħ-Zip 9.20 Copyright (c) 1999-2010 Igor Pavlov Most (de)compression programs have a flag that lists an archive's contents. Invest in faster compression software ( pigz seems like a good choice).Well, that depends on the file.Much more time is spend compressing the data than reading from disk.Speed things up with the -1 flag (accepted answer).I used a script-in-a-script since time seemed to operate only on the first command in a piped sequence (so I made it look like a single command.).I did not bother using the -format option although that would make the log file easier to read.Using /usr/bin/time rather than time, since the built-in command of bash has many fewer options than the GNU command. ![]() I am pretty sure it's not (just) disk access speed, since creating a tar file (that's how the 80G file was created) took just a few minutes (maybe 5 or 10), but after more than 2 hours my simple gzip command is still not done. I get about 500 MB / min conversion speed using top, I seem to be using a single CPU at approximately 100%. ![]() I find myself having to compress a number of very large files (80-ish GB), and I am surprised at the (lack of) speed my system is exhibiting.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |