pat5star
asked on
use find to search through compressed files?
Hi all,
Is it possible? I don't see any option in the man page for this.
I'm looking for an old file on a windows machine with cygwin installed. I tend to compress (and not consistently either, sometimes zip, bzip2, or gzip) old file/directories and lump them all together. I'm sure I have the file somewhere but it is likely compressed in my mess of archives somewhere and I don't want to manually have to search through them all.
Any suggestions?
Thanks,
-Pat
Is it possible? I don't see any option in the man page for this.
I'm looking for an old file on a windows machine with cygwin installed. I tend to compress (and not consistently either, sometimes zip, bzip2, or gzip) old file/directories and lump them all together. I'm sure I have the file somewhere but it is likely compressed in my mess of archives somewhere and I don't want to manually have to search through them all.
Any suggestions?
Thanks,
-Pat
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Err, actually, my above commands would find if it's around but not tell you exactly which archive
the file was found in (fairly useless)
Instead, an approach more like this:
cat zips |xargs --verbose --replace -0 sh -c 'echo "Archive: {}" ; unzip -v "{}" |grep name_search_text'
cat tarballs |xargs --verbose --replace -0 sh -c 'echo "Archive: {}" ; tar tvf "{}" |grep name_search_text'
cat bzip_tarballs |xargs --verbose --replace -0 sh -c 'echo "Archive: {}" ; tar jtvf "{}" |grep name_search_text'
cat gzip |xargs --verbose --replace -0 sh -c 'echo "Archive: {}" ; tar ztvf "{}" |grep name_search_text'
the file was found in (fairly useless)
Instead, an approach more like this:
cat zips |xargs --verbose --replace -0 sh -c 'echo "Archive: {}" ; unzip -v "{}" |grep name_search_text'
cat tarballs |xargs --verbose --replace -0 sh -c 'echo "Archive: {}" ; tar tvf "{}" |grep name_search_text'
cat bzip_tarballs |xargs --verbose --replace -0 sh -c 'echo "Archive: {}" ; tar jtvf "{}" |grep name_search_text'
cat gzip |xargs --verbose --replace -0 sh -c 'echo "Archive: {}" ; tar ztvf "{}" |grep name_search_text'
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Um what's easier with a shareware install Foot? Extending Sunnys script (sorry Mysidia, I've not looked over your scriptlets for sanity... yet:-) to "work" with any number of tools/archivers for finding the archive containing a specific file is trivial.
-- Glenn
-- Glenn
" Um what's easier with a shareware install Foot?"
Hi Glen. he's looking for "an old file". With the emphasis on "an". As in singular. Why bother typing in some of the above code (which may well not work or may be buggy) when he can download a shareware windows program which will do what he wants "out of the box"? A lazy programmer is a good programmer.. You cant get any lazier than not having to program at all. I prefer linux but Im not political about it - if there is an easier windows solution I will use it.
Hi Glen. he's looking for "an old file". With the emphasis on "an". As in singular. Why bother typing in some of the above code (which may well not work or may be buggy) when he can download a shareware windows program which will do what he wants "out of the box"? A lazy programmer is a good programmer.. You cant get any lazier than not having to program at all. I prefer linux but Im not political about it - if there is an easier windows solution I will use it.
ASKER
I awarded a grade of 'A' to this answer as all solutions were very helpful. I awarded 250 points to owensleftfoot because in this particular case I needed to find the file on a windows machine and his suggestion is really the easiest to use and enabled me to find what I needed. I awarded 125 points both to sunnycoder and Mysidia as those scripts should work well for me on my linux machines or even the windows machines that I have cygwin installed on.
Normally I like writing or tweaking scripts to do what I want but this case is different. I needed that file ASAP and really didn't want to spend the time tweaking and testing a script to make sure it's checking all directories, files, and compressed files properly. Later when I have time to spare I will as these are handy scripts that I know I'll need again in the future...at least until I learn how to archive things in a more orderly fashion :P
I hope everyone is happy with the way I split the points and I appreciate the advice. Thanks again,
-Pat
Normally I like writing or tweaking scripts to do what I want but this case is different. I needed that file ASAP and really didn't want to spend the time tweaking and testing a script to make sure it's checking all directories, files, and compressed files properly. Later when I have time to spare I will as these are handy scripts that I know I'll need again in the future...at least until I learn how to archive things in a more orderly fashion :P
I hope everyone is happy with the way I split the points and I appreciate the advice. Thanks again,
-Pat
Thank you Pat for the nice feedback. (And now Foot can say the mandatory "nananananana, I wa-as ri-ight":-):-)
-- Glenn
-- Glenn
lol ... I cant wait to hear that :o)
" Thank you Pat for the nice feedback. (And now Foot can say the mandatory "nananananana, I wa-as ri-ight":-):-)"
Im too much of a gentleman Glen :)
Im too much of a gentleman Glen :)
:-)
-- Glenn
-- Glenn
A similar script can be written for bzip2 or any other archiving program that will let you list the files in the archive
Sunnycoder