Listing the content of a tar file or a directory only down to some level
tar tvf scripts.tar | awk -F/ '{if (NF<4) print }'drwx------ glens/glens 0 2010-03-17 10:44 scripts/-rwxr--r-- glens/www-data 1051 2009-07-27 10:42 scripts/my2cnf.pl-rwxr--r-- glens/www-data 359 2009-08-14 00:01 scripts/pastebin.sh-rwxr--r-- glens/www-data 566 2009-07-27 10:42 scripts/critic.pl-rwxr-xr-x glens/glens 981 2009-12-16 09:39 scripts/wiki_sys.pl-rwxr-xr-x glens/glens 3072 2009-07-28 10:25 scripts/blacklist_update.pl-rwxr--r-- glens/www-data 18418 2009-07-27 10:42 scripts/sysinfo.pl
Make sure to note, that the number is 3+ however many levels you want, because of the / in the username/group. If you just do
tar tf scripts.tar | awk -F/ '{if (NF<3) print }'scripts/scripts/my2cnf.plscripts/pastebin.shscripts/critic.plscripts/wiki_sys.plscripts/blacklist_update.plscripts/sysinfo.pl
it's only two more.
You could probably pipe the output of ls -R
to this awk
script, and have the same effect.
Another option is archivemount. You mount it, and cd into it. Then you can do anything with it just as with other filesystem.
$ archivemount /path/to/files.tgz /path/to/mnt/folder
It seems faster than the tar method.