Search through compressed files


















Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up. Connect and share knowledge within a single location that is structured and easy to search. I'd like to scan my hard drive for all compressed file collections like zip, gzip, bzip, and others and have the content of those searched for certain file types such as images. Anti-virus' do it, so I believe there should be a way. The simplest approach would be to list the contents of the archive and look for files of the relevant extension.

For example, with a zip file:. The -sf option tells zip to list the files contained in an archive. Then, the grep will look for a. The -E enables extended regular expressions, so we can use as OR and the -i makes the matching case insensitive.

However, each archive tool has a different command to list the contents. I've written a script that can deal with most of the more popular ones. That would show you the most common image types. Note that this approach assumes that the file type can be determined by the file's extension. It will not find image files that don't have an extension and it will not recognize files with the wrong extension. There is no way to deal with that without actually extracting the files from the archive and running file on each of them.

How to distribute compressed files as text? Hello everybody, I've seen some text documents where they publish blocks of text and tell you to save it as "file. How is that done? Because i tried cat and doesn't work, tried less, more, hexedit and Search text from a file and print text and one previous line too.

Hi, Please let me know how to find text and print text and its previous line. Please don't get irritated few days back I asked text and next line. I am using HP-UX I have a text file with following content 3 lines filename : output. I tried using cat output. Search first line of compressed file. I want to read a directory full of compressed files and move the file to another directory if it meets certain criteria.

I only want to look at the first line of the compressed file and if I find the string, do the move. I am currently using the following: zgrep -R -L RedHat Commands. OpenSolaris Commands. Linux Commands. SunOS Commands. However, for a busy web or email server, this can be a very large amount of data and is an additional step that is not required because both gzip and bzip2 provide equivalents of less , cat and grep to work directly with the compressed data.

These command work in exactly the same way as their standard counterparts. PowerGREP can search through files stored in these archive formats, but it cannot save modified files back into the archive. PowerGREP does provide extensive options for saving the modified files elsewhere, compressed using one of the above formats, or not. This is the most popular archive format. Incompatible with most ZIP tools, but allows better compression.

TAR uncompressed : Uncompressed tarball. The most popular archive format on Linux, usually compressed using one of the four methods below. GZip : Single file compressed with GZip.



0コメント

  • 1000 / 1000