Recursive directory listings, including, tar, gzip, bzip2

Kevin D. Clark kclark at CetaceanNetworks.com
Mon Sep 8 13:04:56 EDT 2003


"Lee D. Rothstein" <lee at veritech.com> writes:

> Is there a script that comes with Linux,
> (or that you happen to have written)
> that walks down a directory tree and
> recursively lists all subdirectories and
> files, including those contained in:
> 
>  * .tar -- tar balls
>  * .tar.gz -- gzip'ed tar balls
>  * .tar.bz2 -- bzip2'ed tar balls
> 
> If I get 'cpio' and 'rpm', too, that's fine,
> but what I'm really interested in is the
> above.

This comes to mind:

find /somedir \( -name \*.tar.gz -print -exec sh -c 'gzip -dc {} | tar tf -' \; \) -o  \( -name \*.tar.bz2 -print -exec sh -c 'bzip2 -dc {} | tar tf -' \; \) -o \( -name \*.tar -print -exec tar tf {} \; \) -o \( -name \*.rpm -print -exec rpm -q -p {} -l \; \) -o \( -name \*.cpio -print -exec cpio -itI {} \; \) -o -print

Do you want this script to also un-tar tarfiles that are contained in
other tarfiles?  Mine doesn't do this.  You'd have to move away from
this simple one-liner to do this.

Hope this helps,

--kevin
-- 
Kevin D. Clark / Cetacean Networks / Portsmouth, N.H. (USA)
cetaceannetworks.com!kclark (GnuPG ID: B280F24E)
alumni.unh.edu!kdc




More information about the gnhlug-discuss mailing list