Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Listing the content of a tar file or a directory only down to some level

Tags:

bash

ls

tar

depth

I wonder how to list the content of a tar file only down to some level?

I understand tar tvf mytar.tar will list all files, but sometimes I would like to only see directories down to some level.

Similarly, for the command ls, how do I control the level of subdirectories that will be displayed? By default, it will only show the direct subdirectories, but not go further.

like image 809
Tim Avatar asked Apr 23 '10 16:04

Tim


1 Answers

depth=1

tar --exclude="*/*" -tf file.tar 


depth=2

tar --exclude="*/*/*" -tf file.tar 
like image 172
sacapeao Avatar answered Sep 18 '22 13:09

sacapeao