Q:

Extract 3 smallest files from Tar archive in descending order by size

How can I extract from a Tar file in Linux the 3 smallest files in descending order using command line?

A:

You can list the file details, sort by size, pick the top3 files, build the tar x command, and execute to extract the 3 files:
 tar tvf foo.tar
       |awk '$0=$3"\x99"$NF'
       |sort -n
       |awk -F'\x99' 'NR<4{s=s" "$2}END{print "tar xvf foo.tar "s}'
       |sh

Note:

The above one-liner assumes that all filenames in the tarball don't contain spaces or other special characters
The tarball name foo.tar is hardcoded., you should replace it by your real tarball
you can test the cmd without the last pipe: |sh it will only output the generated tar -x command, if it is fine, you can pipe to |sh to do real extraction. 

