6

I use this command to list all files in an archive:

tar jtvf blah.tar.bz2

How to list them sorted by size? Or list only the biggest files (i.e. files bigger than, say, 10MB)?

Basj
  • 41,386
  • 99
  • 383
  • 673

1 Answers1

13

list files, filter by size, print only size+space+path, and sort by size only, descending order:

size=10485760
tar tvf blah.tar.bz2 \
    | awk -v size="$size" '$3 >= size {print $3" "$6}' \
    | sort -t' ' -k1,1nr
Peter
  • 3,067
  • 2
  • 17
  • 18