![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 value from a Log file? | cooolthud | Shell Programming and Scripting | 8 | 04-17-2008 11:30 AM |
| 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 |
| Delete specific lines in a text file | dniz | High Level Programming | 9 | 08-08-2005 08:30 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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 better idea.. thanks Code:
Siebel Enterprise Applications Siebel Server Manager, Version 7.5.3.12 [16272] LANG_INDEPENDENT Copyright (c) 2001 Siebel Systems, Inc. All rights reserved. This software is the property of Siebel Systems, Inc., 2207 Bridgepointe Parkway, San Mateo, CA 94404. User agrees that any use of this software is governed by: (1) the applicable user limitations and other terms and conditions of the license agreement which has been entered into with Siebel Systems or its authorized distributors; and (2) the proprietary and restricted rights notices included in this software. WARNING: THIS COMPUTER PROGRAM IS PROTECTED BY U.S. AND INTERNATIONAL LAW. UNAUTHORIZED REPRODUCTION, DISTRIBUTION OR USE OF THIS PROGRAM, OR ANY PORTION OF IT, MAY RESULT IN SEVERE CIVIL AND CRIMINAL PENALTIES, AND WILL BE PROSECUTED TO THE MAXIMUM EXTENT POSSIBLE UNDER THE LAW. If you have received this software in error, please notify Siebel Systems immediately at (650) 295-5000. Type "help" for list of commands, "help <topic>" for detailed help Connected to 1 server(s) out of a total of 1 server(s) in the enterprise srvrmgr:sble01> list component 'eCustomerCMEObjMgr_enu' SV_NAME CC_ALIAS CC_NAME CT_ALIAS CG_ALIAS CC_RUNMODE CP_DISP_RUN_STATE CP_NUM_RUN_ CP_MAX_TASK CP_ACTV_MTS CP_MAX_MTS_ CP_START_TIME CP_END_TIME CP_STATUS CC_INCARN_NO CC_DESC_TEXT ------- ---------------------- --------------------------------------------------- -------- -------------- ----------- ----------------- ----------- ----------- ----------- ----------- ------------------- ----------- --------- ------------ ------------ sble01 eCustomerCMEObjMgr_enu eCustomer Power Communications Object Manager (ENU) Communications Interactive Running 4 20 1 1 2006-10-16 12:27:03 1 row returned. srvrmgr:sble01> |
|
||||
|
Code:
sed -n "/CP_NUM_RUN_/,/rows* returned./p" file |
awk -v var1="CP_NUM_RUN_" -v var2="CP_MAX_TASK" '
$0 ~ var1 {
flag=1
ind1=index($0,var1);ind2=index($0,var2);
for(i=1;i<=NF;++i)
{
if( $i == var1 ) fld1=i;
if( $i == var2 ) fld2=i;
}
getline
len1=length($fld1)
len2=length($fld2)
getline
}
flag == 1 {
print var1 ": " substr($0,ind1,len1) "\n" var2 ": " substr($0,ind2,len2)
}'
|
|
||||
|
hi anbu,
i implemented your code. i just did a small change. i changed 'awk' to 'nawk' because its solaris OS. I didnt get the output when i used 'awk'. the output of my code is as follows Code:
CP_NUM_RUN_: 3 CP_MAX_TASK: 20 CP_NUM_RUN_: CP_MAX_TASK: CP_NUM_RUN_: CP_MAX_TASK: Code:
CP_NUM_RUN_: 3 CP_MAX_TASK: 20 Code:
+ nawk -v var1=CP_NUM_RUN_ -v var2=CP_MAX_TASK
$0 ~ var1 {
flag=1
ind1=index($0,var1);ind2=index($0,var2);
for(i=1;i<=NF;++i)
{
if( $i == var1 ) fld1=i;
if( $i == var2 ) fld2=i;
}
getline
len1=length($fld1)
len2=length($fld2)
getline
}
flag == 1 {
print var1 ": " substr($0,ind1,len1) "\n" var2 ": " substr($0,ind2,len2)
}
CP_NUM_RUN_: 3
CP_MAX_TASK: 20
CP_NUM_RUN_:
CP_MAX_TASK:
CP_NUM_RUN_:
CP_MAX_TASK:
+ exit
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|