Taking a particular attribute's value in a file...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Taking a particular attribute's value in a file...
# 1  
Old 12-17-2008
Taking a particular attribute's value in a file...

HI,
Iam new to scripting..I need some guidance for invoking the following logic..
My input file contains
Code:
  Event Time = Thu, Nov 6, 2008 08:41:56 AM
                         Probable Cause = UnspecifiedReason
                      Specific Problems = BTS down due to Tx
                                 Domain = Domain 00-00-00-00-00-00-00-A8-1D-4E-91-5D-4C-75:.gp.dm.GSM_dm
                           Alarm Origin = IncomingAlarm
                     Perceived Severity = Critical
                        Additional Text = "NeType: BSC6000| NeLocation: | vendor: | neName: SVHBS150| alarmName: FUEL LEVEL 
                                          LOW| alarmLocation: Site No.=1188,Board Type=70,Board No.=0,PassNo=255,SubLink 
                                          No.=255,CellNo=65535,Site Type=16,RackNo=255,BoxNo=255,SlotNo=255| appendInfo:  
                                          MOI=DC=www.huawei.com , SubNetwork=1 , ManagedElement=7 , BssFunction=0 , 
                                          BtsSiteMgr=1188 
                                          NotificationId=4900 
                                          SpecificProblem=6448 
                                          <ALM_ID>580757<ALM_ID>"
                      Original Severity = Critical
                    Original Event Time = Thu, Nov 6, 2008 08:41:56 AM
                    Problem Occurrences = 1 Problems

Now from the above i need following output:

Code:
Event Time = Thu, Nov 6, 2008 08:41:56 AM

output of this should be
Code:
eventTime=06-11-2008-08-41..
Additional Text = "NeType: BSC6000| NeLocation: | vendor: | neName: SVHBS150| alarmName: FUEL LEVEL 
                                          LOW| alarmLocation: Site No.=1188,Board Type=70,Board No.=0,PassNo=255,SubLink 
                                          No.=255,CellNo=65535,Site Type=16,RackNo=255,BoxNo=255,SlotNo=255| appendInfo:  
                                          MOI=DC=www.huawei.com , SubNetwork=1 , ManagedElement=7 , BssFunction=0 , 
                                          BtsSiteMgr=1188 
                                          NotificationId=4900 
                                          SpecificProblem=6448 
                                          <ALM_ID>580757<ALM_ID>"

IN th einput additional text is containing n number of lines
if iam grepping to display the output only it is giving this value...
Code:
"NeType: BSC6000| NeLocation: | vendor: | neName:

,so I need to take the entire value of Additional text and whenever it has newline ~nl~ has to be appended i.e o/p should be

Code:
NeType: BSC6000| NeLocation: | vendor: | neName: SVHBS150|~nl~alarmName: FUEL LEVEL~nl~  LOW| alarmLocation: Site ~nl~No.=1188,Board Type=70,Board No.=0,PassNo=255,SubLink 
                                         ~nl~ No.=255,CellNo=65535,Site ~nl~Type=16,RackNo=255,BoxNo=255,SlotNo=255| appendInfo:  
                                       ~nl~   MOI=DC=www.huawei.com , ~nl~SubNetwork=1 , ManagedElement=7 , BssFunction=0 , 
                                         ~nl~ BtsSiteMgr=1188 
                                         ~nl~ NotificationId=4900 
                                          ~nl~SpecificProblem=6448 
                                          ~nl~<ALM_ID>580757<ALM_ID>
....

Can anyone help me out for the above scripting....Thanks

Edit: Please use code tags to make it readable. I added tags to make it as readable as possible Smilie
LLB..

Last edited by zaxxon; 12-17-2008 at 10:46 AM.. Reason: Added code tags
# 2  
Old 12-17-2008
I did not follow your question completely but you could get part of your solution by doing something like:

awk '/Additional/,/ID/' file.name
# 3  
Old 12-18-2008
Thanks for the reply...

BUt it didn't work well..
Let us complete one by one..
My input file format is
Event Time = Thu, Nov 6, 2008 08:41:56 AM
Output of the above should be
eventtime=06(DD)-11(MM)-2008(YYYY)-08(HH)-41(MM)
Can anyone guide me for doing scripting fo rthe above..
# 4  
Old 12-18-2008
Code:
#!/bin/sh

date_var=`grep 'Event Time' a.txt | head -1 | cut -d= -f2`
date -d $date_var '+%d-%m-%Y-%H-%M'

# 5  
Old 12-18-2008
It didn't work..but thanks

Hi,
I tried but it is showing -d is not valid option...and hence it is not working..
Can u give any other solution..
Thanks,
Llb
# 6  
Old 12-18-2008
What system are you running this on?
# 7  
Old 12-18-2008
Thsi is my client's system where i can't do any modification..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to check the string in a file and print an attribute in the message

Hi, I am new to shell scripting and got a task to complete. Task is : we have a log file where in i need to traverse through the whole file to check the string "Person Type missing in message" and after that i need to get EMPLID=xxxxxx from the file and print details in a different file. ... (1 Reply)
Discussion started by: suren424
1 Replies

2. Shell Programming and Scripting

Search pattern in a file taking input from another file

Hi, Below is my requirement File1: svasjsdhvassdvasdhhgvasddhvasdhasdjhvasdjsahvasdjvdasjdvvsadjhv vdjvsdjasvdasdjbasdjbasdjhasbdasjhdbjheasbdasjdsajhbjasbjasbhddjb svfsdhgvfdshgvfsdhfvsdadhfvsajhvasjdhvsajhdvsadjvhasjhdvjhsadjahs File2: sdh hgv I need a command such that... (8 Replies)
Discussion started by: imrandec85
8 Replies

3. UNIX for Dummies Questions & Answers

Taking word count from file and printing in file

hi, i am having a file which contains the below content, i need to take the word count of if and print the file name also inputfile.txt file_name1.txt,type_name1.txt file_name2.txt,type_name2.txt i would need the word count of the files like this if file_name*.txt then wc -l... (10 Replies)
Discussion started by: rohit_shinez
10 Replies

4. Red Hat

(.) at the end of file attribute.

Hi Linux Experts, I am using RHEL 6.4, on checking I identified some files ends with the file attribute like dot (.) at the end. Whereas, I checked with the same level of other servers and I don't identify dot(.) at the end of file attribute. Why is it so? is there any meaning for it. ... (3 Replies)
Discussion started by: gsiva
3 Replies

5. Shell Programming and Scripting

Installing a bin file by taking input from a properties file

I need to install a bin file in UNIX which requires user interaction for giving some information like user id , path, sid etc. All these information is stored in a properties file in the same location. So if i give ./file.bin -f propfile.properties will it install the file taking all the... (1 Reply)
Discussion started by: coolmohere
1 Replies

6. Shell Programming and Scripting

How to ftp multiple files by taking the file name from a input file.

Hi, I'm working on a script which has to copy multiple files from one server to another server. The list of files that are to be copied is present in a file say input.txt. vi input.txt abc.c welcome.c new.c welcome1.c for ftp'ing a single file say 'new.c' the following code... (2 Replies)
Discussion started by: i.srini89
2 Replies

7. Shell Programming and Scripting

Changing attribute value in xml file using shell

I have an xml file.I want to change the value of some tag: <WASConfig version='1.1'> <JavaVirtualMachine> <scope> <server> <hostNode>myAsNode</hostNode> <name>myserver</name> </server> </scope> <Settings> <Setting> ... (5 Replies)
Discussion started by: javaholics
5 Replies

8. Programming

UNIX->C++ File attribute

Hi to all, I need in Microsoft C++ to IDENTIFY unix files which are LINKS. I use CFTPFILEFIND class. Thanks :-) .:rolleyes: (0 Replies)
Discussion started by: mizrachi
0 Replies

9. Linux

File attribute Help please

Could anyone help i have a question that i have a problem with for my home work it is, How do i change file permissions in a command line enviromet thanx (1 Reply)
Discussion started by: Cube3k
1 Replies

10. UNIX for Dummies Questions & Answers

File Created On attribute

Hi, I need to find out when a file has been created. 'ls -l' just lists the last date the file was modified. I have also noticed when viewing the attributes through NT, the last modified date is the same as the file creation date. I thought maybe this was a fault due to samba. I guess what... (1 Reply)
Discussion started by: dpalmer
1 Replies
Login or Register to Ask a Question