grep -ip command in Linux


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users grep -ip command in Linux
# 1  
Old 03-16-2011
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:
Code:
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.

Last edited by zaxxon; 03-16-2011 at 09:47 AM.. Reason: code tags
# 2  
Old 03-16-2011
What makes you think this won't work in Linux? This works for me.
# 3  
Old 03-16-2011
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.

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

# 4  
Old 03-16-2011
From "AIX Version 4.3 Commands Reference, Volume 2" (http://www.ualberta.ca/dept/chemeng/...ds2/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.
# 5  
Old 03-17-2011
i use this to simulate grep -p. it's not perfect but works for most situations that I use grep -p for.

awk '/pattern/,/^$/'
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Grep command in Linux in a script where the search string has a space

I have a file xyz with the following content PPPL 0123 PPPL 0006 POFT 0923 POFT 1111 WENT 2323 SEND 2345 I also have another file named MasterFile where it contains the above mentioned data million times with different digits at the end for example some times it contains SEND 9999 or WENT... (4 Replies)
Discussion started by: knijjar
4 Replies

2. UNIX for Beginners Questions & Answers

Simple sed command not working; could be a Mac/Linux vs. PC/Linux issue

Hello, I am on a Mac and trying to clean up some monthly files with a very simple SED: sed '3,10d;/<ACROSS>/,$d' input.txt > output.txt (from the input, delete lines 3 - 10; then delete from the line containing <ACROSS> to the end of the file) then output to output.txt Even when I try... (2 Replies)
Discussion started by: verbatim
2 Replies

3. Shell Programming and Scripting

Grep command giving different result for different users for same command

Hello, I am running below command as root user #nodetool cfstats tests | grep "Memtable switch count" Memtable switch count: 12 Where as when I try to run same command as another user it gives different result. #su -l zabbix -s /bin/bash -c "nodetool cfstats tests | grep "Memtable switch... (10 Replies)
Discussion started by: Pushpraj
10 Replies

4. Shell Programming and Scripting

Issues in grep command in Linux

Hi All I have a file containing following records: $HEW_TGT_DB2_USER=hbme_bi2 $prmAttunityUser=ais $DS_USER=hbme_bi2 $prmStgUser=hbme_bi2 $prmuser=hbme_bi2 $prmStgPass=hbme_bi2 $prmpwd=hbme_bi2 $prmAttunityUser=ais Say suppose the name of the file is test4.txt When i fire this... (5 Replies)
Discussion started by: vee_789
5 Replies

5. Shell Programming and Scripting

Grep command showing wrong output in Linux

Hi All I am trying to run a script in linux wherein i have a command like this grep ^prmAttunityUser= djpHewr2XFMAttunitySetup_ae1_tmp djpHewr2XFMAttunitySetup_ae1_tmp is a temporary file in which the user value is stored but this command in the script returns me balnk value whereas it has a... (4 Replies)
Discussion started by: vee_789
4 Replies

6. Shell Programming and Scripting

can anyone help with shell script command about searching word with grep command?

i want to search in the current directory all the files that contain one word for example "hello" i want to achieve it with the grep command but not with the grep * (2 Replies)
Discussion started by: aintour
2 Replies

7. UNIX for Advanced & Expert Users

how to exclude the GREP command from GREP

I am doing "ps -f" to see my process. but I get lines that one of it represents the ps command itself. I want to grep it out using -v flag, but than I get another process that belongs to the GREP itself : I would like to exclude # ps -f UID PID PPID C STIME TTY TIME CMD... (2 Replies)
Discussion started by: yamsin789
2 Replies
Login or Register to Ask a Question