awk to grep log


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk to grep log
# 1  
Old 12-04-2014
awk to grep log

hi expert,

i Have log like :

Code:
dn: EPC-Per=673,HYHGU
objectClass: EPC-PerSubs
ownerId: 0
groupId: 4001
shareTree: nodeName=HYHGU
permissions: 15
EPC-Per: 673

dn: EPC-SessionId=54454C2D5341534E2D342D302E736170632E64737467726F75702E636F6D3B313430343834313237333B323638343336363430,EPC-Per=673,HYHGU
shareTree: nodeName=HYHGU
permissions: 15
EPC-SessionId: 54454C2D5341534E2D342D302E736170632E64737467726F75702E636F6D3B313430343834313237333B323638343336363430

dn: EPC-SessionId=4453542D5341534E2D342D302E736170632E64737467726F75702E636F6D3B313430353936323432333B323638343336373530,EPC-Per=673,HYHGU
shareTree: nodeName=HYHGU
permissions: 15
EPC-SessionId: 4453542D5341534E2D342D302E736170632E64737467726F75702E636F6D3B313430353936323432333B323638343336373530

dn: EPC-SessionId=54454C2D5341534E2D332D302E736170632E64737467726F75702E636F6D3B313431373635393130323B333031373437343436,EPC-Per=673,HYHGU
shareTree: nodeName=HYHGU
permissions: 15
EPC-SessionId: 54454C2D5341534E2D332D302E736170632E64737467726F75702E636F6D3B313431373635393130323B333031373437343436
EPC-IpAddress: 10.186.22.49
EPC-CalledStationId: internet
EPC-LastActivityTimeStamp: 04-12-2014T16:01:44

dn: EPC-SessionId=54454C2D5341534E2D302D302E736170632E64737467726F75702E636F6D3B313431373634333338393B393436343937313332,EPC-Per=673,HYHGU
shareTree: nodeName=HYHGU
permissions: 15
EPC-SessionId: 54454C2D5341534E2D302D302E736170632E64737467726F75702E636F6D3B313431373634333338393B393436343937313332
EPC-IpAddress: 10.186.173.102
EPC-CalledStationId: internet
EPC-LastActivityTimeStamp: 04-12-2014T13:04:51

i want to print dn session if dont have EPC-IpAdress

so output will be like this :

Code:
EPC-SessionId=54454C2D5341534E2D342D302E736170632E64737467726F75702E636F6D3B313430343834313237333B323638343336363430,EPC-Per=673,HYHGU
EPC-SessionId=4453542D5341534E2D342D302E736170632E64737467726F75702E636F6D3B313430353936323432333B323638343336373530,EPC-Per=673,HYHGU

Thanks
Justbow
# 2  
Old 12-04-2014
Try:
Code:
awk '!/EPC-IpAddress:/{print $2}' RS= file

This User Gave Thanks to Scrutinizer For This Post:
# 3  
Old 12-04-2014
To lose the EPC-Per=673,HYHGU as well, extend above:
Code:
 awk '!/EPC-IpAddress:/ && /EPC-SessionId/ {print $2}' RS= file

This User Gave Thanks to RudiC For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed / awk / grep to extract information from log

Hi all, I have a query that runs that outputs data in the following format - 01/09/12 11:43:40,ADMIN,4,77,Application Group Load: Name(TESTED) LoadId(5137-1-0-1XX-15343-15343) File(/dir/dir/File.T03.CI2.RYR.2012009.11433350806.ARD) InputSize(5344) OutputSize(1359) Rows(2) Time(1.9960)... (8 Replies)
Discussion started by: jeffs42885
8 Replies

2. UNIX for Dummies Questions & Answers

Piping grep into awk, read the next line using grep

Hi, I have a number of files containing the information below. """"" Fundallinfo 6.3950 14.9715 14.0482 """"" I would like to grep for Fundallinfo and use it to read the next line? I ideally would like to read the three numbers that follow in the next line and... (2 Replies)
Discussion started by: Paul Moghadam
2 Replies

3. Shell Programming and Scripting

AWK/GREP: grep only lines starting with integer

I have an input file 12.4 1.72849432773174e+01 -7.74784188610632e+01 12.5 9.59432114416327e-01 -7.87018212757537e+01 15.6 5.20139995965960e-01 -5.61612429666624e+01 29.3 3.76696387248366e+00 -7.42896194101892e+01 32.1 1.86899877018077e+01 -7.56508762501408e+01 35 6.98857157014640e+00... (2 Replies)
Discussion started by: chrisjorg
2 Replies

4. Shell Programming and Scripting

Router ping log extract data from it Awk/Sed/grep

Hi, I am new to this world.. Using expect i loging to router and checking ping response to my links. I need to genarate report using this output and that report contains only three file link name, packet loss, latency. my output of script is like below: -bash-3.00$ monmw/mwbkp... (2 Replies)
Discussion started by: jkmistry
2 Replies

5. Shell Programming and Scripting

Use grep sed or awk to extract string from log file and put into CSV

I'd like to copy strings from a log file and put them into a CSV. The strings could be on different line numbers, depending on size of log. Example Log File: File = foo.bat Date = 11/11/11 User = Foo Bar Size = 1024 ... CSV should look like: "foo.bat","11/11/11","Foo Bar","1024" (7 Replies)
Discussion started by: chipperuga
7 Replies

6. Shell Programming and Scripting

Parsing out access.log with awk and grep

In part of my script I use awk to pull out the urls. awk '{print $8}' then I take them and send them to grep.` Some of them are straight .com/ or .org or whatever (address bar entries), while others are locations of images, js, etc. I'm trying to only pull any line that ends with .com/... (11 Replies)
Discussion started by: druisgod
11 Replies

7. Shell Programming and Scripting

Read content between xml tags with awk, grep, awk or what ever...

Hello, I trying to extract text that is surrounded by xml-tags. I tried this cat tst.xml | egrep "<SERVER>.*</SERVER>" |sed -e "s/<SERVER>\(.*\)<\/SERVER>/\1/"|tr "|" " " which works perfect, if the start-tag and the end-tag are in the same line, e.g.: <tag1>Hello Linux-Users</tag1> ... (5 Replies)
Discussion started by: Sebi0815
5 Replies

8. Shell Programming and Scripting

MEM=`ps v $PPID| grep -i db2 | grep -v grep| awk '{ if ( $7 ~ " " ) { print 0 } else

Hi Guys, I need to set the value of $7 to zero in case $7 is NULL. I've tried the below command but doesn't work. Any ideas. thanks guys. MEM=`ps v $PPID| grep -i db2 | grep -v grep| awk '{ if ( $7 ~ " " ) { print 0 } else { print $7}}' ` Harby. (4 Replies)
Discussion started by: hariza
4 Replies

9. UNIX for Advanced & Expert Users

WEB Server Log File Analysis using awk/sed/grep

I'm trying to find a way to show large page sizes (page size in K) from multiple web server log files. Essentially I want to show only rows from a file where a specific column is larger than some value. Has anyone ever done this type of log analysis? If so, a snippet of code would be very... (2 Replies)
Discussion started by: mike_cataldo@ad
2 Replies

10. UNIX for Dummies Questions & Answers

Constantly updating log files (tail -f? grep? awk?)

I have a log file which is continuously added to, called log.file. I'd like to monitor this file, and when certain lines are found, update some totals in another file. I've played around with tail -f, grep, and awk, but can't seem to hit the right note, so to speak. The lines I'm... (0 Replies)
Discussion started by: nortonloaf
0 Replies
Login or Register to Ask a Question