Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
people, I'm studying grep, but did not understand the -I parameter...
Man grep says:
"Process a binary file as if it did not contain matching data;
this is equivalent to the --binary-files=without-match option."
what it means? Any file should be processed like this (as if it did not contain matching data) right? What it means to process a file as if it did contain matching data?
it means, that binary files are not grepped and don't flood your output with matching messages. Sometimes you want to do a grep pattern * to search for a pattern in a directory containing text and binary files. If you are not interested in matching results from binary files, the -I option helps you to ignore such files.
You can try this in /usr/bin, which contains a mix of shell scripts and binaries. Do a grep print * with and without this option. You'll see the difference.
Jan
Last edited by jan61; 09-16-2008 at 03:11 PM.
Reason: sorry, I meant grep, not sed
This is the part of the man page that tells the story:
Code:
--binary-files=TYPE
If the first few bytes of a file indicate that the file contains
binary data, assume that the file is of type TYPE. By default,
TYPE is binary, and grep normally outputs either a one-line
message saying that a binary file matches, or no message if
there is no match. If TYPE is without-match, grep assumes that
a binary file does not match; this is equivalent to the -I
option. If TYPE is text, grep processes a binary file as if it
were text; this is equivalent to the -a option. Warning: grep
--binary-files=text might output binary garbage, which can have
nasty side effects if the output is a terminal and if the
terminal driver interprets some of it as commands.
Try it on some binary files...First do "cat filename|hexdump -C|more" to see what text strings are there, and then run grep with the different options.
..If TYPE is without-match, grep assumes that a binary file does not match; this is equivalent to the -I option....
All files, which are assumed to be binary by grep, do not output a message about matches. The effect is, that you could grep a number of files without having to take care about unwanted "Binary file /usr/bin/a2p matches" messages.
try it! At my experience it will not work - the options are mutually exclusive. You say "I want binary files to be scanned" and next "I don't want to see binary file's output". The -a option handles binaries like text files (search for a newline or so) and would produce an output you normally do not want to see.
Find out what you get when using the different options. You will not nearly understand what all the options do, if you don't try it on a "real world" system.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.