Substituiton for grep paragraph parameter


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Substituiton for grep paragraph parameter
# 1  
Old 12-21-2010
Substituiton for grep paragraph parameter

My bash doesn't have grep -p.. I often find myself wanting to search a section of a man page for areas dealing with a specific property or parameter... For instance wanting to read everything in the man pages for bash that deal with Parameter Expansion..

Is there a way to do this with grep if you don't have the -p option?

Yes, I know awk can do it.. awk can do everything!
and yes, I know I can download a different grep binary...

I was curious of a way to do it with my grep.. for instance using regex to specify delimiters.
if not please let me know the simplest other solution..
# 2  
Old 12-21-2010
Your bash doesn't have grep period Smilie

The -p option of grep is an AIX thing (at least I think only an AIX thing!). We had a similar "problem" when using Linux servers. We missed the -p option too Smilie

Still, something like this did the trick:

Code:
sed -e '/./{H;$!d;}' -e 'x;/'paragraph_name'/!d;' file


Last edited by Scott; 12-21-2010 at 03:22 PM.. Reason: Changed from "grep -p is an AIX thing" (made it sound like grep was an AIX thing. lol)
# 3  
Old 12-21-2010
grep is not a internal command so its not your bash that has/has not -p option for grep...
To know more about your grep type:
Code:
what <full path to>/grep

# 4  
Old 12-21-2010
Yes, I understand, I should have said my OS doesn't have the grep with the -p option.. I know it's not a shell builtin like IF.. I'll try your suggestion.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to Grep second word in config file using parameter?

Currently i am building one script to grep region records in the config file based on parameter and then i am creating a text file with that out put and i am reading the source file path in that out put file now i need to pass one more parameter like module based upon that it has to create a... (1 Reply)
Discussion started by: saranath
1 Replies

2. UNIX for Dummies Questions & Answers

Getting parameter list is too long in grep command

Hi i am getting below message while using grep command "The parameter list is too long" grep -i 919716499889 * ksh: /usr/bin/grep: 0403-027 The parameter list is too long. please let me know what changes i can do in this command (5 Replies)
Discussion started by: scriptor
5 Replies

3. Shell Programming and Scripting

Using grep and a parameter file to return unique values

Hello Everyone! I have updated the first post so that my intentions are easier to understand, and also attached sample files (post #18). I have over 500 text files in a directory. Over 1 GB of data. The data in those files is organised in lines: My intention is to return one line per... (23 Replies)
Discussion started by: clippertm
23 Replies

4. Shell Programming and Scripting

How to grep paragraph?

Hi, I have A file like this: >Contig1 AAAAAAATTTTTTCCCAATATATGAT ATATATAEATATATAT >Contig2 AAAAAAATTTTTTCCCAATATATGAT ATATATAEAATTTTTAATTTTTTCCCA ATCCCAAATATATAT >Contig3 AAAAAAATTTTTTCCCAATATATGAT ATATATAEAATTTTTAATTTTTTCCCA ATCCCAAATAAATTTTTTCCCAATAT ATGATATATATAEAATTTTTAATTTTT... (3 Replies)
Discussion started by: the_simpsons
3 Replies

5. Shell Programming and Scripting

Command that takes one parameter and then searches for the passed in parameter

Hi I am looking for a unix command or a small shell script which can takes one parameter and then searches for the passed in the parameter in any or all files under say /home/dev/ Can anyone please help me on this? (3 Replies)
Discussion started by: pankaj80
3 Replies

6. UNIX for Dummies Questions & Answers

grep for a backslash as for loop parameter

Hello everyone, My main objective is to search for text within a file, namely a block of text where each line ends with a backslash "\". However, the block must begin with a keyword, like "loginstring". Here is an example of a file that contains a block: ############### loginstring \... (2 Replies)
Discussion started by: idlechatter
2 Replies

7. UNIX for Dummies Questions & Answers

Output text from 1st paragraph in file w/ a specific string through last paragraph of file w/ string

Hi, I'm trying to output all text from the first paragraph in a file that contains a specific string through the last paragraph in that file that contains that string. Previously, I was outputting just each paragraph with that search string with: cat in_file | nawk '{RS=""; FS="\n";... (2 Replies)
Discussion started by: carpenn
2 Replies

8. Shell Programming and Scripting

sum two numbers on a grep commande with the parameter -n

Hello, I want to know how i can sum two numbers in a grep command with the parameter -n. this code return line number and the line who have the "pattern" : *\).*/\1/p') ] but now i want to suw *\).*/\1/p')] with 1 to have the next line: *\).*/\1/p')] + 1 : it can't work. Thanks you (4 Replies)
Discussion started by: samara80
4 Replies

9. Shell Programming and Scripting

how do I make dynamic parameter names? Or get the value of a parameter evaluated twi

Say I write something like the following: var1=1 var2=2 for int in 1 2 do echo "\$var$int" done I want the output to be: 1 2 Instead I get something like: $var1 $var2 (2 Replies)
Discussion started by: Awanka
2 Replies

10. UNIX for Dummies Questions & Answers

Grep 0403-027 The parameter list is too long.

Hi there I get this error message when I try to do a basic grep. Does anyone have any ideas what is wrong. Thanks 0403-027 The parameter list is too long. (1 Reply)
Discussion started by: japada
1 Replies
Login or Register to Ask a Question