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.

it depends.

what does the file look like? Give us its format.

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

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>

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

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

You mean you want to print only those lines where both log file names are not identical? Then try something like this:

awk '$2 != $3' 123.log

It'll yeild:

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.

You can try using this with the previous command :

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