Finding string and getting formatted ouput


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Finding string and getting formatted ouput
# 1  
Old 06-30-2009
Finding string and getting formatted ouput

I have follwoing text file as alarm dump.

Code:
A1/EXT "B25I11K0150_F W" 512 090629   1121      
RADIO X-CEIVER ADMINISTRATION
BTS EXTERNAL FAULT
MO                    RSITE            CLASS
RXOCF-405         DKRD01_INDS      1
EXTERNAL ALARM
MAINS FAIL                                                    
DOOR OPEN                                                     
H C T ON        

A1/EXT "B25I11K0150_F W" 523 090629   0627      
RADIO X-CEIVER ADMINISTRATION
BTS EXTERNAL FAULT
MO                    RSITE            CLASS
RXOCF-153         ACHL01_INDS      1
EXTERNAL ALARM
MAINS FAIL                                                    
BBU AC UNIT FAULTY                                            
BBU DOOR OPEN    
 
A1/EXT "B25I11K0150_F W" 299 090629   1710      
RADIO X-CEIVER ADMINISTRATION
BTS EXTERNAL FAULT
MO                    RSITE            CLASS
RXOCF-255         JHOT01_GIL       1
EXTERNAL ALARM
MAINS FAIL                                                    
DOOR OPEN

i need help for scripting to get below out put
1) Search " Mains Fail "

and give out put
Code:
JHOT01_GIL         090629   1710
ACHL01_INDS       090629   0627
DKRD01_INDS       090629   1121

in new file

Lal Chand

Last edited by Yogesh Sawant; 06-30-2009 at 07:04 AM.. Reason: added code tags
# 2  
Old 06-30-2009
Try the below...


Code:
cat temp.txt | egrep "A1/EXT|RXOCF" | paste - - | awk '{print $8,$5,$6}'

Note: temp.txt will be the input file.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Finding a string in a file

Hello All, I have a text file, i want to search for a string in it and the string is repeated multiple times in a file i want to get the first occurence of the string in a variable. the content of file is like: I want to grepthe first occurance of "Configuration flow done" and store the... (7 Replies)
Discussion started by: anand2308
7 Replies

2. Shell Programming and Scripting

finding the Last String in a Line

Hi, i am looking for a command that can help me find the last Sting in a Line ex.. yyeyrtehhehrerry: change this from to here i want to extract END. (5 Replies)
Discussion started by: Rohit1234
5 Replies

3. Shell Programming and Scripting

How to get the formatted string with reg?

Source is " LG 0 0 18 14 172.16.2.20 1 2 OK T OK T OK T" How to get the following format string with reg? LG 0 0, 18 Thanks in advance. (10 Replies)
Discussion started by: janex
10 Replies

4. Shell Programming and Scripting

Finding a string with another string is found

finding a string with another string is found EX: abs c/- i want to find /-, then copy abs. i know it's easy use awk, but my problem is the substr syntax. substr($2,2,2) will give me /- but the conflict is /- is not always the second characted of the second string. (11 Replies)
Discussion started by: engr.jay
11 Replies

5. Shell Programming and Scripting

String searching and output to a file in a formatted text

Hi, I'm very new to UNIX scripting and find quite difficult to understand simple UNIX syntax. Really appreciat if somebody could help me to give simple codes for my below problems:- 1) I need to search for a string "TTOH 8031950001" in a files which filename will be "*host*'. For example, the... (3 Replies)
Discussion started by: cuji
3 Replies

6. UNIX for Dummies Questions & Answers

finding my location in a string

I'm a relative newbie and apologize if this is silly... Suppose I have a file with English words and their Spanish translations. I read them in like this: while(getline < myfile > 0) { eng = $1 SPAN = $2 } Now, for every eng in SPAN, I want to scan through SPAN and search for a... (2 Replies)
Discussion started by: DrLeeDetroit
2 Replies

7. Shell Programming and Scripting

Finding a letter in a string

How to check whether a particular string contains dot or not? Here I can not use grep as the string is not in a file. I will get this string from user input Thanks, (2 Replies)
Discussion started by: balamv
2 Replies

8. Shell Programming and Scripting

More formatted string

In a large file i need last line of the file but I want ignore first charcter, ignore leading zeros after first character and print the remaining character as such. Is something i can do it by tail or wc? cat test1 .... ...... 8000003687 cat test2 .... ...... 8000538990 o/p 3687 538990 (3 Replies)
Discussion started by: ford2020
3 Replies

9. Shell Programming and Scripting

Convert DATE string to a formatted text

Hi guys, i need your help. I need to convert a date like this one 20071003071023 , to a formated date like 20071003 07:10:23 . Could this be possible ? Regards, Osramos (6 Replies)
Discussion started by: osramos
6 Replies

10. Shell Programming and Scripting

help with finding a string

Hello folks I have a text file abcd.txt and has a line starting with number '8'. I have a string in this line starting at position 'a' to position 'b' also this string is a number and have to be reduced by 1. there is also a problem that it has to be padded with zeros to make the string... (2 Replies)
Discussion started by: sandyg
2 Replies
Login or Register to Ask a Question