problem parsing output file

Hi Gurus,

I am using the following code to parse the output of a file. This code basically parses the file and adds | at the end of each field. But I am getting it wrong in some cases. I have explained it below

#----- parse output file, get each field position, -----
#----- and construct command string                -----
LINE=`cat $temp_output_tasks | grep "\-\-"`
count=1
PreCHR="-"

while [ 1 ]
do
    CHR=`echo "$LINE" | cut -c$count`
    if [[ -z $CHR ]]
    then
      break
    fi

    if [ "$CHR" != "$PreCHR" ]
    then
      if [ "$CHR" != "-" ]
      then
        #--Find the end point of the field, write it to command--
        pos=$count
        (( pos -= 1 ))
        command=$command" | perl -pe'substr(\$_,$pos,1)=\"|\";'"
      fi
    fi
    PreCHR=$CHR
    (( count += 1 ))
done
#----- Now we have the positon of each field, run the command, ----
#----- and add "|" at the end of each field                    ----

command="grep ^sblp $temp_output_tasks"$command
eval $command > $outputs

#----- Remove white space ----
sed 's/ \{1,\}\|/\|/g' < $outputs > $temp_output_tasks
sed 's/|\ \{1,\}/\|/g' < $temp_output_tasks > $outputs

The file that needs to be parsed looks like this

Siebel Enterprise Applications Siebel Server Manager, Version 7.8.2.3 [19221] 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 48 server(s) out of a total of 54 server(s) in the enterprise

srvrmgr> list tasks show SV_NAME TK_PID TK_START_TIME TK_PID TK_DISP_RUNSTATE TK_PID TK_END_TIME TK_PID TK_TASKID TK_PID TK_LABEL TK_PID TK_PID TK_PID CC_ALIAS

SV_NAME  TK_START_TIME        TK_DISP_RUNSTATE  TK_END_TIME          TK_TASKID  TK_LABEL       TK_PID  CC_ALIAS                
-------  -------------------  ----------------  -------------------  ---------  -------------  ------  ----------------------  
sblp001  2007-03-19 17:28:45  Completed         2007-03-19 17:28:45  152473                            eCommunicationsObjMgr_enu

but I get this as output whenever there is @ character in one of the fields

sblp001|2007-03-19 17:20:49|Running||151115|anderst22@bp.|om  258|6   eCustomerCMEObjMgr_|nu  

This should actually read like below

sblp001|2007-03-19 17:20:49|Running||151115|anderst22@bp.com |2586|  eCustomerCMEObjMgr_enu  

Please help oyt guys. thanks in advance

#!/usr/bin/ksh

PATTERN=`grep "^--" <file> | sed -e "s/-  -/-\\\\\)  \\\\\(-/g" -e "s/^/\\\\\(/" -e "s/$/\\\\\)/" -e "s/-/\./g"`
grep "^sbl" <file> | sed -e "s/${PATTERN}/\1|\2|\3|\4|\5|\6|\7|\8/" -e "s/[ ]*|[ ]*/|/g"

Independant of number of columns and number of spaces between columns:

#!/usr/bin/ksh

PATTERN1=`grep "^--" test | sed -e "s/-[ ][ ]*-/-\\\\\)[ ][ ]*\\\\\(-/g" -e "s/^/\\\\\(/" -e "s/$/\\\\\)/" -e "s/-/\./g"`

typeset -i FIELDS=`grep "^--" test | wc -w`

COUNT=1
while [ ${COUNT} -le ${FIELDS} ]
do
  PATTERN2="${PATTERN2}|\\${COUNT}"
  ((COUNT=${COUNT}+1))
done

PATTERN2=`echo "${PATTERN2}" | sed -e "s/^|//"`

grep "^sbl" test | sed -e "s/${PATTERN1}/${PATTERN2}/" -e "s/[ ]*|[ ]*/|/g"

Ooooooooooops

Problem is caused because

-------------
anderst22@bp.com

The value is more charecters then the number of dashes "-" indicating the field length

how do I correct that problem.. please suggest some modifications to the code for me to correct the issue.. its really urgent

hi sbp008

thanks a lot for your reply..

your code is working exactly as expected. however i have one more question, i want to store the output of your grep into another file. how do i do that. please help me out with that.

thanks in advance.

Hii. Your code is giving me issues as well. I am getting output like the one below in cases where there are more than 7 fields. please tell me how to correct that. i am really bad at shell scripting and I am just in learning phase..

sblp008  2007-03-20 10:45:22  Running                                261451    BMilstead4755  10718   eCustomerCMEObjMgr_enu  

I am getting an output like this sporadically from your code.

sblp011  2007-03-20 11:01:03  Running                                115548     EMPANON        6342    eCommunicationsObjMgr_enu  

I want output for all the records to be like this

sblp011|2007-03-20 11:01:03|Running|115548|EMPANON|6342|eCommunicationsObjMgr_enu  

Hi..

its not happen sporadically as i said in my last post. it happens when the input file ahs the value 'Exited with error' in one of the fileds like this

sblp006  2007-03-19 03:57:45  Exited with error  2007-03-19 04:13:50  234728     sadmin                 MqSeriesAMIRcvr         

the output appears this way for these values alone like this

sblp007  2007-03-19 03:57:45  Exited with error  2007-03-19 04:13:47  255494     sadmin                     MqSeriesAMIRcvr         

thanks

this problem also happens if there are more than 7 field in the input file even without having the value "Exited with error" likr this

sblp009  2007-03-20 11:21:34  Running                                108149     EMPANON            2244    eCommunicationsObjMgr_enu  

There is no way to correct it based on the concept as presented.

For the simple reason that some fields have an value with a length which exceeds the length for the specific field as indicated by the "dash" line.

There might be another way to parse it correctly into the format which you desire. However to do so, there needs to be a method which identifies exactly to which column a specific value belongs.

I would have to see the full input file, that is exactly as it is with the right amount of spaces shown, to see if there is a way to parse the file correct.

Probably the easiest option would be if your "srvrmgr" command would generate output with the correct format. That is all fields either have a fixed length or your the dashes in the dashed line have at least as many dashes for each field as the longest output value for that specific field.

Hi sb008..

I am pasting below the output of srvrmgr command. please have a look at it and tell me there is a way to parse it the way I desire.

Thanks

Siebel Enterprise Applications Siebel Server Manager, Version 7.8.2.3 [19221] 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 48 server(s) out of a total of 54 server(s) in the enterprise

srvrmgr> list tasks show SV_NAME TK_PID TK_START_TIME TK_PID TK_DISP_RUNSTATE TK_PID TK_END_TIME TK_PID TK_TASKID TK_PID TK_LABEL TK_PID TK_PID TK_PID CC_ALIAS

SV_NAME  TK_START_TIME        TK_DISP_RUNSTATE  TK_END_TIME          TK_TASKID  TK_LABEL       TK_PID  CC_ALIAS                
-------  -------------------  ----------------  -------------------  ---------  -------------  ------  ----------------------  
sblp001  2007-03-20 10:54:04  Running                                261827     INT_PORTAL     25832   eCustomerCMEObjMgr_enu  
sblp001  2007-03-20 10:51:41  Completed         2007-03-20 10:51:41  261323                            WfProcMgr               
sblp001  2007-03-20 10:46:35  Completed         2007-03-20 10:46:35  260295     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 10:40:15  Completed         2007-03-20 10:40:16  258962                            WfProcMgr               
sblp001  2007-03-20 10:37:32  Completed         2007-03-20 10:37:32  258344                            WfProcMgr               
sblp001  2007-03-20 10:35:32  Completed         2007-03-20 10:35:33  257928     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 10:35:03  Completed         2007-03-20 10:35:04  257824     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 10:24:39  Completed         2007-03-20 10:24:40  255662                            WfProcMgr               
sblp001  2007-03-20 10:22:55  Completed         2007-03-20 10:22:56  255297     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 10:21:19  Completed         2007-03-20 10:21:19  254968     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 10:19:10  Completed         2007-03-20 10:24:24  254494     SIEBELSSOUSER          eCustomerSSOObjMgr_enu  
sblp001  2007-03-20 10:19:01  Completed         2007-03-20 10:35:53  254472     JEIJEIJEI              eCustomerSSOObjMgr_enu  
sblp001  2007-03-20 10:14:34  Completed         2007-03-20 10:16:44  253586     bkonynenbelt           eCustomerSSOObjMgr_enu  
sblp001  2007-03-20 10:11:03  Completed         2007-03-20 10:11:04  252872                            WfProcMgr               
sblp001  2007-03-20 09:52:12  Completed         2007-03-20 09:52:13  249420                            WfProcMgr               
sblp001  2007-03-20 09:21:56  Completed         2007-03-20 09:21:57  243456                            WfProcMgr               
sblp001  2007-03-20 09:21:02  Completed         2007-03-20 09:21:02  243283                            WfProcMgr               
sblp001  2007-03-20 09:15:08  Running                                242170     INT_PORTAL     25840   eCustomerCMEObjMgr_enu  
sblp001  2007-03-20 09:04:53  Completed         2007-03-20 09:04:54  240291                            WfProcMgr               
sblp001  2007-03-20 08:46:40  Running                                237004     INT_PORTAL     25844   eCustomerCMEObjMgr_enu  
sblp001  2007-03-20 08:30:40  Completed         2007-03-20 08:30:40  233900                            WfProcMgr               
sblp001  2007-03-20 08:25:44  Completed         2007-03-20 08:25:44  232993     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 08:23:28  Completed         2007-03-20 08:23:28  232683     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 08:23:04  Completed         2007-03-20 08:23:04  232621     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 08:21:55  Completed         2007-03-20 08:21:56  232442     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 08:21:47  Completed         2007-03-20 08:21:48  232429                            WfProcMgr               
sblp001  2007-03-20 08:21:40  Completed         2007-03-20 08:21:40  232411     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 08:20:20  Completed         2007-03-20 08:20:21  232203                            WfProcMgr               
sblp001  2007-03-20 08:19:45  Completed         2007-03-20 08:19:46  232128     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 08:18:10  Completed         2007-03-20 08:18:10  231927                            WfProcMgr               
sblp001  2007-03-20 08:17:38  Completed         2007-03-20 08:17:38  231832                            WfProcMgr               
sblp001  2007-03-20 08:15:56  Completed         2007-03-20 08:15:57  231514     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 08:14:55  Completed         2007-03-20 08:14:55  231267     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 08:14:28  Completed         2007-03-20 08:14:29  231185     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 08:13:29  Completed         2007-03-20 08:28:33  231032     rcr292103              eCustomerSSOObjMgr_enu  
sblp001  2007-03-20 08:12:55  Completed         2007-03-20 08:12:55  230937                            WfProcMgr               
sblp001  2007-03-20 08:11:10  Completed         2007-03-20 08:11:11  230716     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 08:10:50  Completed         2007-03-20 08:10:50  230678     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 08:10:00  Completed         2007-03-20 08:10:01  230606     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 08:09:50  Completed         2007-03-20 08:09:51  230583     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 08:07:23  Completed         2007-03-20 08:07:23  230234     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 08:04:17  Completed         2007-03-20 08:04:17  229824     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 08:00:55  Running                                229380     INT_WBI        25795   EAIObjMgr_enu           
sblp001  2007-03-20 07:58:54  Completed         2007-03-20 07:58:55  229092     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 07:58:20  Completed         2007-03-20 07:58:21  228962     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 07:58:19  Completed         2007-03-20 07:58:20  228960     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 07:58:18  Completed         2007-03-20 07:58:20  228958     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 07:56:02  Completed         2007-03-20 07:56:02  228610     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 07:55:33  Completed         2007-03-20 07:55:33  228567                            WfProcMgr               
sblp001  2007-03-20 07:51:32  Completed         2007-03-20 07:51:32  228101     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 07:49:45  Completed         2007-03-20 07:49:45  227906     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 07:47:53  Completed         2007-03-20 07:47:53  227572     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 07:47:32  Completed         2007-03-20 07:47:38  227532     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 07:47:25  Completed         2007-03-20 07:47:25  227490     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 07:39:31  Completed         2007-03-20 07:39:31  226472     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 07:38:47  Running                                226400     INT_PORTAL     25815   eCustomerCMEObjMgr_enu  
sblp001  2007-03-20 07:38:46  Completed         2007-03-20 07:38:47  226397     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 07:31:29  Running                                225729     INT_PORTAL     25840   eCustomerCMEObjMgr_enu  
sblp001  2007-03-20 07:31:20  Completed         2007-03-20 07:31:20  225708                            WfProcMgr               
sblp001  2007-03-20 07:24:15  Completed         2007-03-20 07:24:16  224800     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 07:11:39  Completed         2007-03-20 07:11:39  223380                            WfProcMgr               
sblp001  2007-03-20 06:25:05  Completed         2007-03-20 06:25:06  219878     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 06:22:12  Running                                219658     INT_PORTAL     25827   eCustomerCMEObjMgr_enu  
sblp001  2007-03-20 06:15:15  Completed         2007-03-20 06:15:16  219260                            WfProcMgr               
sblp001  2007-03-20 05:42:50  Running                                217704     INT_PORTAL     25822   eCustomerCMEObjMgr_enu  
sblp001  2007-03-20 05:07:36  Completed         2007-03-20 05:07:36  216687                            WfProcMgr               
sblp001  2007-03-20 02:27:09  Completed         2007-03-20 02:27:10  214239                            WfProcMgr               
sblp001  2007-03-20 01:54:46  Completed         2007-03-20 01:54:47  213607                            WfProcMgr               
sblp001  2007-03-20 01:43:08  Completed         2007-03-20 01:43:09  213377     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 01:40:49  Completed         2007-03-20 01:40:49  213278     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 01:40:47  Completed         2007-03-20 01:40:47  213274     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 01:38:45  Completed         2007-03-20 01:38:46  213238     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 01:34:54  Completed         2007-03-20 01:34:54  213177     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 01:31:01  Completed         2007-03-20 01:31:01  213080     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 01:28:35  Completed         2007-03-20 01:28:36  213003     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 01:27:59  Completed         2007-03-20 01:27:59  212987     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 01:27:50  Completed         2007-03-20 01:27:51  212986     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 01:22:54  Completed         2007-03-20 01:22:54  212876     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-20 00:51:38  Completed         2007-03-20 00:51:38  211906                            WfProcMgr               
sblp001  2007-03-20 00:48:45  Completed         2007-03-20 00:48:45  211766                            WfProcMgr               
sblp001  2007-03-20 00:32:00  Completed         2007-03-20 00:32:01  211156                            WfProcMgr               
sblp001  2007-03-20 00:11:30  Completed         2007-03-20 00:11:30  210305                            WfProcMgr               
sblp001  2007-03-20 00:09:25  Completed         2007-03-20 00:09:26  210147                            WfProcMgr               
sblp001  2007-03-20 00:09:22  Completed         2007-03-20 00:09:22  210145                            WfProcMgr               
sblp001  2007-03-20 00:09:17  Completed         2007-03-20 00:09:17  210141                            WfProcMgr               
sblp001  2007-03-20 00:08:30  Completed         2007-03-20 00:08:30  210061                            WfProcMgr               
sblp001  2007-03-20 00:08:29  Completed         2007-03-20 00:08:29  210060                            WfProcMgr               
sblp001  2007-03-20 00:08:27  Completed         2007-03-20 00:08:27  210057                            WfProcMgr               
sblp001  2007-03-20 00:08:24  Completed         2007-03-20 00:08:24  210056                            WfProcMgr               
sblp001  2007-03-20 00:08:21  Completed         2007-03-20 00:08:21  210054                            WfProcMgr               
sblp001  2007-03-20 00:08:17  Completed         2007-03-20 00:08:17  210053                            WfProcMgr               
sblp001  2007-03-20 00:08:13  Completed         2007-03-20 00:08:13  210018                            WfProcMgr               
sblp001  2007-03-20 00:07:59  Completed         2007-03-20 00:07:59  209991                            WfProcMgr               
sblp001  2007-03-19 23:57:04  Running                                209371     INT_PORTAL     25860   eCustomerCMEObjMgr_enu  
sblp001  2007-03-19 23:52:09  Completed         2007-03-20 12:38:53  209110     INT_PORTAL             eCustomerCMEObjMgr_enu  
sblp001  2007-03-19 23:02:37  Running                                206866                    25762   SRBroker                
sblp001  2007-03-19 22:45:38  Completed         2007-03-19 22:45:38  204607                            WfProcMgr               
sblp001  2007-03-19 22:37:26  Completed         2007-03-19 22:58:48  203646     drnick46               eCustomerSSOObjMgr_enu  
sblp001  2007-03-19 22:17:35  Completed         2007-03-19 22:17:35  201363                            WfProcMgr               
sblp001  2007-03-19 21:35:09  Completed         2007-03-19 21:35:10  195191                            WfProcMgr               
sblp001  2007-03-19 21:33:21  Completed         2007-03-19 21:33:21  194954                            WfProcMgr               
sblp001  2007-03-19 21:15:13  Completed         2007-03-19 21:15:13  192176                            WfProcMgr               
sblp001  2007-03-19 20:49:17  Completed         2007-03-19 20:49:18  188039                            WfProcMgr               
sblp001  2007-03-19 20:40:02  Completed         2007-03-19 20:40:02  186426                            WfProcMgr               
sblp001  2007-03-19 20:39:51  Completed         2007-03-19 20:39:51  186379                            WfProcMgr               
sblp001  2007-03-19 20:34:03  Completed         2007-03-19 20:34:03  185293                            WfProcMgr               
sblp001  2007-03-19 20:18:16  Completed         2007-03-19 20:18:16  182343                            WfProcMgr               
sblp001  2007-03-19 20:01:24  Completed         2007-03-19 20:01:25  179370                            WfProcMgr               
sblp001  2007-03-19 19:58:52  Completed         2007-03-19 19:58:52  178922                            WfProcMgr               
sblp001  2007-03-19 19:55:47  Completed         2007-03-19 19:55:47  178449                            WfProcMgr               
sblp001  2007-03-19 19:54:30  Completed         2007-03-19 19:54:31  178239                            WfProcMgr               
sblp001  2007-03-19 19:53:47  Completed         2007-03-19 19:53:47  178124                            WfProcMgr               
sblp001  2007-03-19 19:51:25  Completed         2007-03-19 19:51:26  177781                            WfProcMgr               
sblp001  2007-03-19 19:51:14  Completed         2007-03-19 19:51:15  177746                            WfProcMgr               
sblp001  2007-03-19 19:50:31  Completed         2007-03-19 19:50:31  177630                            WfProcMgr               
sblp001  2007-03-19 19:46:31  Completed         2007-03-19 19:46:32  176781                            WfProcMgr               
sblp001  2007-03-19 19:42:43  Completed         2007-03-19 19:42:43  176013                            WfProcMgr               
sblp001  2007-03-19 19:33:38  Completed         2007-03-19 19:33:39  174557                            WfProcMgr               
sblp001  2007-03-19 19:32:00  Completed         2007-03-19 19:32:01  174240                            WfProcMgr               
sblp001  2007-03-19 19:30:44  Completed         2007-03-19 19:30:45  173964                            WfProcMgr               
sblp001  2007-03-19 19:22:02  Completed         2007-03-19 19:22:02  172486                            WfProcMgr               
sblp001  2007-03-19 19:16:25  Completed         2007-03-19 19:16:25  171347                            WfProcMgr               
sblp001  2007-03-19 19:13:44  Completed         2007-03-19 19:13:45  170815                            WfProcMgr               
sblp001  2007-03-19 19:13:41  Completed         2007-03-19 19:13:42  170802                            WfProcMgr               
sblp001  2007-03-19 18:22:24  Completed         2007-03-19 18:22:24  162025                            WfProcMgr               
sblp001  2007-03-19 18:14:47  Completed         2007-03-19 18:14:47  160716                            WfProcMgr               
sblp001  2007-03-19 18:12:04  Completed         2007-03-19 18:12:04  160252                            WfProcMgr               
sblp001  2007-03-19 18:05:43  Completed         2007-03-19 18:05:43  159323                            WfProcMgr               
sblp001  2007-03-19 18:02:27  Completed         2007-03-19 18:02:28  158685                            WfProcMgr               
sblp001  2007-03-19 17:58:28  Completed         2007-03-19 17:58:28  158078                            WfProcMgr               
sblp001  2007-03-19 17:49:13  Completed         2007-03-19 17:49:13  156439                            WfProcMgr               
sblp001  2007-03-19 17:46:40  Completed         2007-03-19 17:46:41  155908                            WfProcMgr               
sblp001  2007-03-19 17:46:18  Completed         2007-03-19 17:46:19  155777                            WfProcMgr               
sblp001  2007-03-19 17:42:41  Completed         2007-03-19 17:42:41  154945                            WfProcMgr               
sblp001  2007-03-19 17:41:35  Completed         2007-03-19 17:41:36  154792                            WfProcMgr               
sblp001  2007-03-19 17:37:25  Completed         2007-03-19 17:37:26  154060                            WfProcMgr               
sblp001  2007-03-19 17:37:14  Completed         2007-03-19 17:37:15  154035                            WfProcMgr               
sblp001  2007-03-19 17:35:36  Completed         2007-03-19 17:35:37  153755                            WfProcMgr               
sblp001  2007-03-19 17:33:04  Completed         2007-03-19 17:33:05  153382                            WfProcMgr               
sblp001  2007-03-19 17:29:59  Completed         2007-03-19 17:29:59  152821                            WfProcMgr               
sblp001  2007-03-19 17:29:15  Completed         2007-03-19 17:29:16  152639                            WfProcMgr               
sblp001  2007-03-19 17:26:24  Completed         2007-03-19 17:41:58  152011     ResLife1               eCustomerSSOObjMgr_enu  
sblp001  2007-03-19 16:58:03  Completed         2007-03-19 16:58:05  147328     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-19 16:35:37  Completed         2007-03-19 16:35:37  143089     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-19 16:33:38  Completed         2007-03-19 16:33:38  142745     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-19 16:23:36  Completed         2007-03-19 16:23:36  140671     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-19 16:15:22  Completed         2007-03-19 16:15:22  139247     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-19 15:55:04  Completed         2007-03-19 15:55:06  135354     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-19 15:39:40  Completed         2007-03-19 15:39:41  132271     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-19 15:39:39  Completed         2007-03-19 15:39:40  132261     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-19 15:23:49  Completed         2007-03-19 15:23:49  129308     INT_ESF                EAIObjMgr_enu           
sblp001  2007-03-19 14:51:26  Completed         2007-03-19 14:56:43  122792     SIEBELSSOUSER

Ok, my bad, I should have been more specific.

I need an exact example of an output file which contains a MIXTURE of those lines which are parsed wrong and those lines which are parsed correct.

The file as you posted it, would parse completely correct using the script I gave you

Hi sb008..

Thanks for all your help.. It was not your bad, but I was unable to attach the whole file for some reasons.

I finally figured a way to correct that. There is an inbuilt functionality in the srvrmgr command that helped me delimit the values using a '|'

After that I used the below code to get the desired output

command="grep ^sblp $temp_output_tasks "$command
eval $command > $output

#----- Remove white space ----
sed 's/ \{1,\}\|/\|/g' < $output > $temp_output_tasks
sed 's/|\ \{1,\}/\|/g' < $temp_output_tasks > $output