LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 09-16-2008, 12:22 PM   #1
gustavolinux
Member
 
Registered: Aug 2008
Posts: 36

Rep: Reputation: 15
grep -I


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?

thanxs
 
Old 09-16-2008, 02:19 PM   #2
jan61
Member
 
Registered: Jun 2008
Posts: 235

Rep: Reputation: 46
Moin,

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
 
Old 09-16-2008, 02:28 PM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
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.
 
Old 09-16-2008, 03:10 PM   #4
jan61
Member
 
Registered: Jun 2008
Posts: 235

Rep: Reputation: 46
Moin,

no, THIS is the only important man page part:
Quote:
Originally Posted by pixellany View Post
..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.

It's not a question of different binary types.

Jan
 
Old 09-16-2008, 03:42 PM   #5
gustavolinux
Member
 
Registered: Aug 2008
Posts: 36

Original Poster
Rep: Reputation: 15
ok, i think I understood...

I could use -a together with -I ?

in case I dont want this "matches"messages in my output, but i do want to "scan" binary files?

tanx again
 
Old 09-16-2008, 03:56 PM   #6
jan61
Member
 
Registered: Jun 2008
Posts: 235

Rep: Reputation: 46
Moin,

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.

Jan

Last edited by jan61; 09-16-2008 at 03:57 PM.
 
Old 09-17-2008, 08:19 AM   #7
gustavolinux
Member
 
Registered: Aug 2008
Posts: 36

Original Poster
Rep: Reputation: 15
really... the command

grep -a -I 'umask.*mask' ./testetemp.iso

did nothing... mutually exclusive parameters, really...

tanx dudes
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to understand pipes - Can't pipe output from tail -f to grep then grep again lostjohnny Linux - Newbie 15 03-12-2009 10:31 PM
how to grep multiple filters with grep LinuxLover Linux - Enterprise 1 10-18-2007 07:12 AM
grep output on stdout and grep output to file don't match xnomad Linux - General 3 01-13-2007 04:56 AM
bash script with grep and sed: sed getting filenames from grep odysseus.lost Programming 1 07-17-2006 11:36 AM
ps -ef|grep -v root|grep apache<<result maelstrombob Linux - Newbie 1 09-24-2003 11:38 AM


All times are GMT -5. The time now is 09:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration