LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Solaris / OpenSolaris (https://www.linuxquestions.org/questions/solaris-opensolaris-20/)
-   -   text manipulation, REGEX plus the following line (https://www.linuxquestions.org/questions/solaris-opensolaris-20/text-manipulation-regex-plus-the-following-line-532813/)

farkus888 02-27-2007 03:05 AM

text manipulation, REGEX plus the following line
 
I have been trying to find a way to do this for a while but I can't seem to find the right way to search to find my answer. I need to be able to search through large amounts of text and find my REGEX and then send the line containing the REGEX and the immediately following it to the a text file. I think I can figure out how to redirect the output on my own so no assistance needed there. before it comes up "grep -A1" does not seem to work, I am assuming that is because I am using an old version (solaris 5.9).

jlliagre 02-27-2007 11:21 AM

Actually, you are expecting a standard compliant grep to accept a GNU specific extension.

On recent Solaris releases, GNU grep is available as /usr/sfw/bin/ggrep, not sure about Solaris 9 but you certainly can download it.

mdhmi 02-27-2007 04:02 PM

What type of text manipulation are you trying to accomplish with "grep"? Nawk and Perl are your friends, remember. :)

farkus888 02-27-2007 06:26 PM

unfortunately nawk and perl are not within my knowledge base. I did try to use sed but couldn't make it work and my knowledge of awk doesn't extend beyond setting a delimiter and selecting columns from a text stream. I am still pretty new to scripting and aside from 3 or 4 short emails from my boss I am completely self taught. I will put them on my to learn list though so I can use them in the future.

unfortunately where I work there is NO adding of software to our solaris machines. but luckily ggrep is on them already and it seems to do an excellent job at the task at hand. thanks for the helpful reply jlliagre.


All times are GMT -5. The time now is 02:56 AM.