Remove unwanted data?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Remove unwanted data?
# 15  
Old 05-09-2007
Quote:
Originally Posted by radoulov
Code:
sed -n '
/Event Id:/ b block
H
$ b block
b
:block
x
/INFO/!p' infile

Thanks a lot - that worked like a charm!!!
# 16  
Old 05-09-2007
have you tried Ygor's method?
# 17  
Old 05-09-2007
The Ygor's method doesn't work on my AIX box.
My awk version uses only the first character of RS.

Try the following awk program :
Code:
#!/usr/bin/awk -f 
function print_lines() {
   for (i=1; i<= lines_count; i++)
      print lines[i];
}
/^Event Id:/ {
   if (! ignore_event)
      print_lines();
   lines_count  = 0;
   ignore_event = 0;
}
! ignore_event {
   if (/^Type : INFO/) 
      ignore_event = 1;
   else
      lines[++lines_count] = $0;
}
END {
   print_lines();
}


Jean-Pierre.
# 18  
Old 05-09-2007
Yes i tried that but that doesnt work for me on my AIX.

Aigles, Could you please let me know how am i suppose to run your script??? I mean how do i pass the data to the awk script????? and also, radoulov's code???
# 19  
Old 05-09-2007
Quote:
Originally Posted by hitmansilentass
Yes i tried that but that doesnt work for me on my AIX.

Aigles, Could you please let me know how am i suppose to run your script??? I mean how do i pass the data to the awk script????? and also, radoulov's code???
Code:
awk -f <awk_program_name> filename

# 20  
Old 05-09-2007
That didnt work either. anyways, could any one of you please explain me the code of radoulov
# 21  
Old 05-09-2007
Quote:
Originally Posted by hitmansilentass
That didnt work either. anyways, could any one of you please explain me the code of radoulov
It's explained in Sed - An Introduction and Tutorial by Bruce Barnett (under Flow Control).
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with parsing data with awk , eliminating unwanted data

Experts , Below is the data: --- Physical volumes --- PV Name /dev/dsk/c1t2d0 VG Name /dev/vg00 PV Status available Allocatable yes VGDA 2 Cur LV 8 PE Size (Mbytes) 8 Total PE 4350 Free PE 2036 Allocated PE 2314 Stale PE 0 IO Timeout (Seconds) default --- Physical volumes ---... (5 Replies)
Discussion started by: rveri
5 Replies

2. Shell Programming and Scripting

Remove unwanted white space

Hi, I have a very big file 25GB with information present in it like $ head ind_stats update index statistics pfirm001.dbo.Office using 200 values go ... (11 Replies)
Discussion started by: sam05121988
11 Replies

3. Shell Programming and Scripting

How to remove unwanted " from string...

I have this Input File with extra double quotes in the middle. Please suggest how to handle this condition. Input File: "123985","SAW CUT CONCRETE SLAB 20"THICK",,"98.57","","EACH","N" "204312","ARMAFLEX-1 3/8 X 3"",,"2.48","","PER FOOT","N" "205745","MISTING HEAD HOLLOW CONE "C"... (3 Replies)
Discussion started by: BICC
3 Replies

4. Shell Programming and Scripting

How to remove unwanted strings?

Hi Guys, Can someone give me a hand on how I can remove unwanted strings like "<Number>" and "</Number>" and retain only the numbers from the input file below. INPUT FILE: <Number>10050000</Number> <Number>1001340001</Number> <Number>1001750002</Number> <Number>100750003</Number>... (8 Replies)
Discussion started by: pinpe
8 Replies

5. Shell Programming and Scripting

remove unwanted text using perl

Hello..I have a text file that need to remove unwanted text. This is the original file. No. Time Source Destination Protocol Info 16 0.649949 10.1.1.101 209.225.11.237 HTTP POST /scripts/cms/xcms.asp HTTP/1.1 ... (9 Replies)
Discussion started by: taxi
9 Replies

6. Shell Programming and Scripting

Remove unwanted lines

I have a .xml file, where i need some output. The xml file is like: Code: <?******?></ddddd><sssss>234</dfdffsdf><sdhjh>534</dfdfa>......... /Code I need the output like: code 234 534 . . . /code How can i do it? (5 Replies)
Discussion started by: anupdas
5 Replies

7. Emergency UNIX and Linux Support

Remove Unwanted Libraries - optimizing

We have a huge makefile composing of inclusion of libraries, objects and system libraries to generate a binary. How do we find out that which of the libraries we can remove in the most efficient way? Doing hit and trial method is a waste of time and can during the linking with some post linking... (12 Replies)
Discussion started by: uunniixx
12 Replies

8. Solaris

Remove unwanted packages

I got a system which was installed with SUNWCXall cluster installed on it and i want remove unwanted software like GMNOME, Java Desktop System, Staroffice and numerous other softwares .. i want to do an automated removal of these packages where its uninstalled by itself ..from the is there any... (4 Replies)
Discussion started by: fugitive
4 Replies

9. UNIX for Advanced & Expert Users

How to Remove the unwanted Blank Lines

I have a file with the below data, i would like to remove the end blank lines with no data. I used the below commands but could not able to succeed, could you please shed some light. Commands Used: sed '/^$/d' input.txt > output.txt grep -v '^$' input.txt > output.txt input.txt file... (5 Replies)
Discussion started by: Ariean
5 Replies

10. Shell Programming and Scripting

Remove unwanted XML Tags

I have set of sources and the respective resolution. Please advice how to resolve the same using Unix shell scripting. Source 1: ======= <ext:ContactInfo xmlns:ext="urn:AOL.FLOWS.Extensions"> <ext:InternetEmailAddress>AOL@AOL.COM</ext:InternetEmailAddress> </ext:ContactInfo> Resoultion... (1 Reply)
Discussion started by: ambals123
1 Replies
Login or Register to Ask a Question