How to read a specific value from a Log file?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to read a specific value from a Log file?
# 1  
Old 01-27-2007
How to read a specific value from a Log file?

Hi,

I have a .log file in which it has many values. But i need some specific values. How it can be done using Shell Script. Please explain in detail.

Thankx in advance.

Sathish D V.
# 2  
Old 01-27-2007
Quote:
Originally Posted by cooolthud
Hi,

I have a .log file in which it has many values. But i need some specific values. How it can be done using Shell Script. Please explain in detail.
it depends.

what does the file look like? Give us its format.
# 3  
Old 01-27-2007
Please post here a sample log file and the specific values you are looking for. Please be little more specific, if you want a general answer then I can tell you that to look for specific values in a specific log file there are many tools, like grep, sed, awk, perl, bash, ksh, sh whatsoever suits you.

Regards,
Tayyab
# 4  
Old 01-27-2007
Some more details would be nice.

But finding a specific value in a file:

grep <value> <file>

Or multiple values:

egrep "<value1>|<value2>|<value3>" <file>
# 5  
Old 01-27-2007
Quote:
Originally Posted by tayyabq8
Please post here a sample log file and the specific values you are looking for. Please be little more specific, if you want a general answer then I can tell you that to look for specific values in a specific log file there are many tools, like grep, sed, awk, perl, bash, ksh, sh whatsoever suits you.

Regards,
Tayyab
Hi the log file looks like below:

Database Name AAALog BBB Log
#===================================================================#
XXXXXX S0000993.LOG S0000992.LOG
YYYYYY S0002549.LOG S0002549.LOG

I need to print only the difference of the S0000993.LOG and S0000992.LOG using Shell script. If we open 123.log then the output looks as above shown.

Can u suggest how to do this?
Thanks
Sathish D V
# 6  
Old 01-27-2007
for eg: you have a logfile called itr.log means and you want to get root name and read that means below is the way.

grep "root" itr.log|read a
echo $a

in the above example you grep for root,then store the grep output in a variable a

then you can echo and check whether stored value is correct
# 7  
Old 01-27-2007
Quote:
Originally Posted by cooolthud
Hi the log file looks like below:

Database Name AAALog BBB Log
#===================================================================#
XXXXXX S0000993.LOG S0000992.LOG
YYYYYY S0002549.LOG S0002549.LOG

I need to print only the difference of the S0000993.LOG and S0000992.LOG using Shell script. If we open 123.log then the output looks as above shown.

Can u suggest how to do this?
Thanks
Sathish D V
You mean you want to print only those lines where both log file names are not identical? Then try something like this:
Code:
awk '$2 != $3' 123.log

It'll yeild:
Code:
XXXXXX                  S0000993.LOG        S0000992.LOG

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Search for a specific String in a log file for a specific date range

Hi, I have log file which rolls out every second which is as this. HttpGenRequest - -<!--OXi dbPublish--> <created="2014-03-24 23:45:37" lastMsgId="" requestTime="0.0333"> <response request="getOutcomeDetails" code="114" message="Request found no matching data" debug="" provider="undefined"/>... (3 Replies)
Discussion started by: karthikprakash
3 Replies

2. Shell Programming and Scripting

To read specific line from a file

Hi, I have a ldif file like below: version: 1 dn: cn=Test Group,ou=Applications,dc=xyz,dc=com objectClass: groupOfUniqueNames objectClass: top cn: Test Group uniqueMember: uid=abc,ou=People,o=xyz,o=Corporate,dc=xyz,dc=com dn: cn=Test Sub Group,cn=Test... (4 Replies)
Discussion started by: saurau
4 Replies

3. Shell Programming and Scripting

Read in specific lines in a file

I have a text file First title line name1 name2 name3 name4 (etc) other lines other lines other lines I want to read in this text file and parse the name1...name4 to a variable. How do I specificially read in these lines and these lines only? (10 Replies)
Discussion started by: piynik
10 Replies

4. Shell Programming and Scripting

How to read particular line in file from specific column?

Hi...friends.... I want to create inventory...information for that I need to read some specific row say 2nd row from 1st 3 column and and write data with particular file used, I have some more column also but I need only 3 column data of first entry after header I attached sample file..those... (12 Replies)
Discussion started by: nex_asp
12 Replies

5. Shell Programming and Scripting

how read specific line in a file and write it in a new text file?

I have list of files in a directory 'dir'. Each file is of type HTML. I need to read each file and get the string which starts with 'http' and write them in a new text file. How can i do this shell scripting? file1.html <head> <url>http://www.google.com</url> </head> file2.html <head>... (6 Replies)
Discussion started by: vel4ever
6 Replies

6. Shell Programming and Scripting

read data from file from a specific duration

Hi, i have log file which keeps on updating almost ever minute but i have certain string in log which will only be displayed between specific time. so i need to search for that string and copy the details starting from that string and stop at certain string below that. example: log file... (2 Replies)
Discussion started by: gpk_newbie
2 Replies

7. Shell Programming and Scripting

Read from file specific place in file using inode

Hello, I am using tcsh on AIX. I would like to write a script that does the following: 1. given an inode, how do I find exactly the name of the file? I know I could do this using ls -i | grep <inode> but it returns: <inode> <filename>. I need some string manipulation or something to... (1 Reply)
Discussion started by: lastZenMaster
1 Replies

8. Shell Programming and Scripting

read from a specific pattern from one file and append it to another

Hi! Everyone, Say this file1 -------------- line 1 51610183 420001010 0010CTCTLEDPPOO 2151610183 line 2 2151610183 420001010 0030A2TH2 line 3 2151610183 420001010 0040A2TH3 line 4 2151610183 420001010 ... (0 Replies)
Discussion started by: kinkar_ghosh
0 Replies

9. Shell Programming and Scripting

read specific text from a log file

Hi guys I need to retrieve the values in BOLD that I have mentioned in the below log file. I want to store those values in a variable, preferably the same name as the column name in the log file. if you paste the below mentioned log file in a notepad and remove the word wrap.. u will get a... (4 Replies)
Discussion started by: ragha81
4 Replies

10. Programming

How to read specific lines in a bulk file using C file Programming

Please Help me I have a Bulk file containing Hex data I want to read specific lines from that bulk file by ID number. example ID DATE Time data 14 2005/09/28 07:40:08.546 0 5 078B1C 01916C 0FE59C 004B54 0A9670 0D04ED 05B6B4 0E2223... (10 Replies)
Discussion started by: rajan_ka1
10 Replies
Login or Register to Ask a Question