The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
read space filled file and replace text at specific position COD Shell Programming and Scripting 6 04-21-2008 05:40 AM
How to read a specific section and modify within kn.naresh Shell Programming and Scripting 2 04-18-2008 12:30 AM
read specific text from a log file ragha81 Shell Programming and Scripting 4 10-17-2006 01:17 PM
How to read specific lines in a bulk file using C file Programming rajan_ka1 High Level Programming 10 11-10-2005 03:29 AM
Shell Script to read specific lines in a file varshanswamy Shell Programming and Scripting 5 08-22-2005 07:12 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-27-2007
cooolthud cooolthud is offline
Registered User
  
 

Join Date: Jan 2007
Posts: 4
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 (permalink)  
Old 01-27-2007
milhan milhan is offline
Registered User
  
 

Join Date: Oct 2002
Location: /home
Posts: 133
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 (permalink)  
Old 01-27-2007
tayyabq8's Avatar
tayyabq8 tayyabq8 is offline Forum Advisor  
Moderator
  
 

Join Date: Nov 2004
Location: Bahrain
Posts: 579
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 (permalink)  
Old 01-27-2007
cooolthud cooolthud is offline
Registered User
  
 

Join Date: Jan 2007
Posts: 4
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
  #5 (permalink)  
Old 01-27-2007
tayyabq8's Avatar
tayyabq8 tayyabq8 is offline Forum Advisor  
Moderator
  
 

Join Date: Nov 2004
Location: Bahrain
Posts: 579
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
  #6 (permalink)  
Old 01-28-2007
cooolthud cooolthud is offline
Registered User
  
 

Join Date: Jan 2007
Posts: 4
Quote:
Originally Posted by tayyabq8
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
Hi,
Thank u very much. But i need one more help. I have shown a values as S0000993.LOG, here i need to remove 'S' and '.LOG' from the shown value. And only print '0000993'. Is it possible? If so can please explain?

Thanks and Regards
Sathish D V.
  #7 (permalink)  
Old 04-17-2008
harpreetanand harpreetanand is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 11
You can try using this with the previous command :

awk '$2 != $3' 123.log | sed -e s/S//g -e s/.LOG//g
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:17 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0