Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 07-18-2009, 11:08 PM   #1
Registered: Jan 2009
Posts: 31

Rep: Reputation: 15
tar -tf going slow

I recently created a tar file containing several large files(like 50-200 MB each). I understand that it could take a while to add or extract large files, but I am just trying to list the files in the archive.

I do a "tar -tf file.tar", and it takes like 3 minutes to list the 15 files in the archive. Don't tar files keep an index of the files added to them?

So, is this normal behavior? why would filesize affect the time it takes to list files?
Old 07-19-2009, 12:13 AM   #2
Senior Member
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Yes, it seems to be normal behavior. No, there is almost certainly no index created by tar for its archives. (Where would it live?)

I did a little experiment to confirm what you're describing:
$ du -h foo bar baz boo
4.0K    foo
4.0K    bar
338M    baz
331M    boo

$ tar cf one.tar foo bar

$ tar cf two.tar baz boo

$ time tar tf one.tar 

real    0m0.171s
user    0m0.000s
sys     0m0.001s

$ time tar tf two.tar 

real    0m14.560s
user    0m0.027s
sys     0m1.266s
It took the one.tar archive (which contains tiny files) a fraction of a second to be listed. It took the two.tar archive (which contains 300MB+ files) over 14 seconds to be listed.

My WAG is he is actually extracting files to a temporary area - or /dev/null - just to do the listing. I didn't measure disk I/O, but I suspect you'd find lots of activity while listing a large archive.
Old 07-19-2009, 05:49 PM   #3
Registered: Jan 2009
Posts: 31

Original Poster
Rep: Reputation: 15
I would have expected that there was some kind of table of contents or index at the beginning of a tar file. kind of like with filesystems. I mean, an empty tar archive takes up 10K. It seems so inefficient to extract every file in a tar when you only need to list filenames. especially with large files.

Last edited by plebetan; 07-19-2009 at 09:18 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i decompress this tar.tar file? hmmm sounds new.. tar.tar.. help ;) kublador Linux - Software 14 10-25-2016 02:48 AM
BackUp & Restore with TAR (.tar / .tar.gz / .tar.bz2 / tar.Z) asgarcymed Linux - General 5 12-31-2006 02:53 AM
is it me, or is tar slow? yekibud Slackware 33 05-04-2005 03:43 PM
scp slow for tar files? kloppster Linux - Software 4 08-21-2004 08:14 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:17 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration