LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 09-30-2005, 10:42 AM   #1
ahz10
Member
 
Registered: Apr 2005
Distribution: Fedora,Trustix,FreeBSD
Posts: 62

Rep: Reputation: 15
show biggest files in tar archive?


I have a 1GB .tar.bz2. Does anyone know a command to sort the contents by size?

This would be the tar equivalent to something like

Code:
du | sort -rn
The problem with tar's listing is that the size isn't first.
 
Old 09-30-2005, 11:34 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
Hi,

Does this help:

tar tvf /path/to/tar.tar | sort -k3

This will sort the output of tar tvf (ls -l alike style) and is sorted on the third field (-k3).

Hope this helps.
 
Old 11-04-2005, 03:26 PM   #3
ahz10
Member
 
Registered: Apr 2005
Distribution: Fedora,Trustix,FreeBSD
Posts: 62

Original Poster
Rep: Reputation: 15
druuna,

Thanks, the -k3 is what I needed. It helps me find the biggest files in my nightly incremental backups.

By the way, sort also needs -n for natural sort.
 
Old 11-04-2005, 03:48 PM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
Hi,

Your welcome

BTW: sort -n is for numeric-sort (compare according to string numerical value).
Personally I don't have to use the -n option, output is the same. But the results may differ depending on linux/unix flavor and/or different versions of sort.
 
  


Reply


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
old tar? archive maenho Linux - Software 4 12-14-2006 07:05 PM
Recovering files from corrupt TAR archive... johnwyles Linux - Software 8 04-17-2006 04:44 AM
How to list the files in my tar.bz2 archive ??? merlin23 Linux - Newbie 13 12-14-2004 08:50 AM
Tar gives error when creating a tar file archive davidas Linux - Newbie 10 04-13-2004 12:35 AM
this doesn't look like a tar archive .phister Slackware 5 02-01-2004 01:19 AM


All times are GMT -5. The time now is 10:53 AM.

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