Find all tar and compressed file

Hi,

I'm trying to find all tar and compressed files (say gzip). I'm having to assume that the tar and gzip files may or may not have the correct extension (.tar .gz .tgz etc).

Any help appreciated

first, find out what your file command thinka about your compressed files

#example
file chessle_uspletr_1735747.lis.gz
chessle_uspletr_1735747.lis.gz: gzip compressed data - deflate method , original file name , max compression

Do that for each of the compressed types you have on your system. On the box I am currently connected to the results from my file command:

all types you want have the word 'compress' in them.

This is inherently inefficient but the plus at the end of the find command makes it more efficient, your system may not support that:

find / -type f -exec file {} + | grep compress > compressed_files.txt

This assumes that you cannot rely on filenames at all to tell you if a file is compressed or not.

find . -type f \( -name "*.gz" -o -name "*.tar" -o -name "*.zip" \) -exec ls -l {} \;