|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | 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 Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Filter a particular string
Hi, I have a long log file. Out of which I want to filter particular occurrences where APC=4-033-0. Please help how it can be done. Input : Code:
+++ ELEMENT 12-05-27 23:15:06 CC 3482 #040185 > REPT APB TPE=C7NTL SM=22 OPC=4-003-7 APC=4-033-4 inaccessible END OF REPORT #040185 ++- +++ ELEMENT 12-05-27 23:15:56 CC 3482 #040187 > REPT APB TPE=C7NTL SM=22 OPC=4-003-7 APC=4-033-0 inaccessible END OF REPORT #040187 ++- +++ ELEMENT 12-05-27 23:16:26 CC 3482 #040188 > REPT APB TPE=C7NTL SM=22 OPC=4-003-7 APC=4-033-6 inaccessible END OF REPORT #040188 ++- Output : Code:
OPC=4-003-7 APC=4-033-0 inaccessible 12-05-27 23:15:56 Thanks in advance. Last edited by Scrutinizer; 06-04-2012 at 02:52 AM.. Reason: code tags |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Based on the input given .. Code:
$ nawk '/APC=4-033-0/{print $5,$6,$7,x};{x=$3" "$4}' infile
OPC=4-003-7 APC=4-033-0 inaccessible 12-05-27 23:15:56 |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Quote:
It works Fine..But getting blank lines in between output. How to suppress them. |
|
#4
|
||||
|
||||
|
Pipe output to Code:
| sed '/^ *$/d' |
| Sponsored Links | |
|
|
#6
|
||||
|
||||
|
Optimal method: Code:
| awk NF -- Quote:
Last edited by Scrutinizer; 06-04-2012 at 05:34 AM.. |
| The Following User Says Thank You to Scrutinizer For This Useful Post: | ||
vanand420 (06-04-2012) | ||
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
Thanks..executing the above code "| awk NF" resolved the case.
|
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to filter | Naga06 | Shell Programming and Scripting | 6 | 07-18-2011 03:20 AM |
| AWK filter | ultimatix | Shell Programming and Scripting | 8 | 11-19-2010 01:30 AM |
| Sed filter words from string | amicon007 | Shell Programming and Scripting | 7 | 09-13-2010 09:41 AM |
| filter the string from a file ?? | varungupta | Shell Programming and Scripting | 11 | 09-17-2007 10:11 PM |
| Filter using awk | arun_st | UNIX for Dummies Questions & Answers | 3 | 03-21-2007 08:20 AM |
|
|