![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| grep and display few lines before and after | melanie_pfefer | SUN Solaris | 8 | 09-25-2008 08:05 AM |
| grep a word and display its column | Orbix | UNIX for Dummies Questions & Answers | 1 | 12-24-2007 05:32 PM |
| How to display first 7 char of grep results? | kthatch | UNIX for Dummies Questions & Answers | 8 | 04-04-2007 10:00 PM |
| using cat and grep to display missing records | jxh461 | UNIX for Dummies Questions & Answers | 4 | 01-13-2007 06:56 AM |
| Make grep -c display like grep -n? | Jerrad | Shell Programming and Scripting | 2 | 08-24-2006 09:20 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have the following data:
A 1 2 3 A 4 5 6 A 7 8 9 I want to grep this data with A and 3 lines below it then display them in this format: A 1 2 3 A 4 5 6 A 7 8 9 My grep comand is: grep +3 "A" datafile Can someone help me to have the data lay out as describe above? Many thanks! |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
I am not sure that you understand the grep command because it seems as though you are trying to format data which is in a fixed order, rather than search for specific patterns of text - which is the main function of grep.
Please confirm this before I continue with some possibilities that may apply? |
|
#3
|
|||
|
|||
|
I understand the grep. I just need help with the arrangement of the data.
My data: A 1 2 3 A 4 5 6 A 7 8 9 Need to be: A 1 2 3 A 4 5 6 A 7 8 9 Thanks! |
|
#4
|
||||
|
||||
|
Code:
nawk 'ORS=(FNR%4)?FS:"\n"' myFile.txt |
|
#5
|
|||
|
|||
|
This is working GREAT! Thank you much!
|
|||
| Google The UNIX and Linux Forums |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|