Filter some text


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Filter some text
# 1  
Old 07-31-2008
Filter some text

Dear experts,

Below i have mentioned two alarms with MAJOR severity, i am intrested only with alarm contains text tre , actually i want to filter out alarm which is highlighted in bold text in some other file for further processing.

I need all above three line of the alarm containing text tre

Please help me with this......

SEV="MAJOR": RX-TX [10] HW-FAILURE [239] DOMAIN="alcomc2_BSS_52
unit-type % bts nbr % 5
SBL-type % ra nbr % 1 subnb % 255

SEV="MAJOR": RX-TX [10] HW-FAILURE [239] DOMAIN="alcomc2_BSS_20
unit-type % bts nbr % 24

SBL-type % tre nbr % 4 subnb % 255


Thanks a lot.
Best Regards.
# 2  
Old 07-31-2008
Code:
open(FH,"<a");
while(<FH>){
	$array[$.%3]=$_;
	if((index $array[0],"tre")!=-1){
		print $array[1];
		print $array[2];
		print $array[0];
	}
}
close(FH);

# 3  
Old 07-31-2008
Filter text

Dear Cherry,

Thanks a lot for the script,
I am using your script like mentioned below:
This help.txt file contains all the alarms, is it ok because it is not running on my system, dear can you please tell me from this script how can i filter out my desired alarm in other file.

THANKS A LOT.

open(help.txt,"<a");
while(<help.txt>){
$array[$.%3]=$_;
if((index $array[0],"tre")!=-1){
print $array[1];
print $array[2];
print $array[0];
}
}
close(help.txt);
# 4  
Old 07-31-2008
Filter text

Dears Friends,

Kindly help me with this any idea will be highly appriciated.

Thanks a lot.
Best Regards.Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Filter all the lines with minimum specified length of words of a text file

Hi Can someone tell me which script will work best (in terms of speed and simplicity to write and run) for a large text file to filter all the lines with a minimum specified length of words ? A sample script with be definitely of great help !!! Thanks in advance. :) (4 Replies)
Discussion started by: my_Perl
4 Replies

2. UNIX for Dummies Questions & Answers

Grep : Filter/Move All The Lines Containing Not More Than One "X" Character Into A Text File

Hi All It's me again with another huge txt files. :confused: What I have: - I have 33 huge txt files in a folder. - I have thousands of line in this txt file which contain many the letter "x" in them. - Some of them have more than one "x" character in the line. What I want to achieve:... (8 Replies)
Discussion started by: Nexeu
8 Replies

3. UNIX for Dummies Questions & Answers

Filter records in a huge text file from a filter text file

Hi Folks, I have a text file with lots of rows with duplicates in the first column, i want to filter out records based on filter columns in a different filter text file. bash scripting is what i need. Data.txt Name OrderID Quantity Sam 123 300 Jay 342 498 Kev 78 2500 Sam 420 50 Vic 10... (3 Replies)
Discussion started by: tech_frk
3 Replies

4. UNIX for Dummies Questions & Answers

Solaris - Filter columns in text file and adding new column

Hello, I am very now to this, hope you can help, I am looking into editing a file in Solaris, with dinamic collums (lenght varies) and I need 2 things to be made, the fist is to filter the first column and third column from the file bellow file.txt, and create a new file with the 2 filtered... (8 Replies)
Discussion started by: jpbastos
8 Replies

5. Shell Programming and Scripting

Find patterns and filter the text

I need to filter the text in between two patterns and output that to a different file. Please help me how to do it. Ex: ............. <some random text> ............. Pattern_1 <Few lines that need to be output to different file> Pattern_2 ................ ............... <more text in... (4 Replies)
Discussion started by: metturr
4 Replies

6. Shell Programming and Scripting

Filter or remove duplicate block of text without distinguishing marks or fields

Hello, Although I have found similar questions, I could not find advice that could help with our problem. The issue: We have several hundreds text files containing repeated blocks of text (I guess back at the time they were prepared like that to optmize printing). The block of texts... (13 Replies)
Discussion started by: samask
13 Replies

7. Shell Programming and Scripting

Filter text after keyword

I've got a little problem to solve and can't find a way to solve it. If have text line like the following: keyword1: text1 keyword2: text2 keyword3: text3 Now I need a script or command, which gives me the text for the corresponding keyword. The text can consist of only one or more words.... (5 Replies)
Discussion started by: frankbullitt78
5 Replies

8. Shell Programming and Scripting

Shell script to read lines in a text file and filter user data

hi all, I have this file with some user data. example: $cat myfile.txt FName|LName|Gender|Company|Branch|Bday|Salary|Age aaaa|bbbb|male|cccc|dddd|19900814|15000|20| eeee|asdg|male|gggg|ksgu|19911216||| aara|bdbm|male|kkkk|acke|19931018||23| asad|kfjg|male|kkkc|gkgg|19921213|14000|24|... (4 Replies)
Discussion started by: srimal
4 Replies

9. Shell Programming and Scripting

Filter duplicate block of text using SED

Hi, I would like to print a block of text between 2 regular expression using Sed, This can be achieved by using the command as shown below, however my problem is the same block of text is repeated twice. I would like to eliminate the duplicate block of text. For Example If my file... (5 Replies)
Discussion started by: dkumar91
5 Replies

10. Windows & DOS: Issues & Discussions

Filter data from text file

Hi All We have got a text file, which has data dumped from 60 tables. From these 60 tables of data we need data from 4 tables only. I tried assigning line numbers to filter out data, but it is not working as intended. below is the sample file ----Table1----- 3,dfs,43,df 4,sd,5,edd... (18 Replies)
Discussion started by: b_sri
18 Replies
Login or Register to Ask a Question