grep -ip command in Linux

Hi,

As you know we can capture paragraph information using -ip command with grep option in AIX and other OS. Is there anything similar to this command in linux to capture paragraph infroamtion?

coammnd:

cat a.out | grep -ip "Word1"

Thanks

---------- Post updated at 07:38 PM ---------- Previous update was at 01:45 PM ----------

Hi,

Any clue on this please? Appreciate your quick response on this.

Thanks
Jayaprakash.

What makes you think this won't work in Linux? This works for me.

Don't bump posts to get a faster response. You agreed not to do that when you registered, and we even have an "emergency" forum for things that need a quick response.

GNU grep definitely does not have "-p". It has "-P" which is not the same thing.

What exactly does this "-p" option do in AIX? What do you mean by paragraph information? Islands of text surrounded by blank lines? you could use awk's record separator feature to read text in that kind of blocks. awk will read entire blocks of text separated by newlines when RS="", which you can match and print. GNU awk should be able to handle blocks of substantial size.

awk 'BEGIN{ RS="" } /match/ { print $0 }' < filename

From "AIX Version 4.3 Commands Reference, Volume 2" (http://www.ualberta.ca/dept/chemeng/AIX-43/share/man/info/C/a\_doc_lib/cmds/aixcmds2/grep.htm\):
-p[Separator] Displays the entire paragraph containing matched lines. Paragraphs are delimited by paragraph separators, as specified by the Separator parameter, which are patterns in the same form as the search pattern. Lines containing the paragraph separators are used only as separators; they are never included in the output. The default paragraph separator is a blank line.
Also, as a note:
Paragraphs (under the -p flag) are currently limited to a length of 5000 characters.
Ergo, no. Linux grep has nothing like this AFAIK.

i use this to simulate grep -p. it's not perfect but works for most situations that I use grep -p for.

awk '/pattern/,/^$/'