Format data output result


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Format data output result
# 1  
Old 10-08-2012
Format data output result

Hi guys, need a guide to format desire output result here. Please guide me. Thanks in advance.

Code:
2012-08-30 00:01:56,554 DEBUG [SendThread - SingleMode] [com.psa.infra.cei.MessageProcessor] - Sending message<TTT232MM0N048YCI             TTPC    TTOF1A 289171092679389OOLU 1562340 TPM 641  KT$YES  20120830000156KK 12012301??????000011YGY> to 117.58.169.109:12137
2012-08-30 00:01:58,577 DEBUG [Thread-1] [com.psa.infra.cei.CEIMessageReceiver] - Received server message: 91|TTT232MC00640      TTT232    TTAC1YOOLU 1562340 Y      0
2012-08-30 00:23:57,293 DEBUG [SendThread - SingleMode] [com.psa.infra.cei.MessageProcessor] - Sending message<TTT232MM0N078YCI             TTPC    TTOF1B 289171092683100TCLU 3192440 TPM 469  KT$YES  20120830002357KK 12012302??????000011YGY> to 117.58.169.109:12137
2012-08-30 00:23:59,476 DEBUG [Thread-1] [com.psa.infra.cei.CEIMessageReceiver] - Received server message: 91|TTT232MC00649      TTT232    TTAC1YTCLU 3192440 Y      0
2012-08-30 00:26:28,721 DEBUG [SendThread - SingleMode] [com.psa.infra.cei.MessageProcessor] - Sending message<TTT232MM0N085YCI             TTPC    TTOF1D 289171092682132SEGU 4021510 TPM 251  KT$YES  20120830002628KK 12022201??????000011YGY> to 117.58.169.109:12137
2012-08-30 00:26:31,294 DEBUG [Thread-1] [com.psa.infra.cei.CEIMessageReceiver] - Received server message: 91|TTT232MC00651      TTT232    TTAC1YSEGU 4021510 Y      0

Desire result:
2012-08-30 00:01:58,577 - 2012-08-30 00:01:56,554 2.23
Code:
send_datetime, receive_datetime, send trans ID , receive ID, time_difference(sent - receive), raw sending msg, raw receive msg
2012-08-30 00:01:56, 2012-08-30 00:01:58, TTOF1A, TTAC1, 2.23,TTT232MM0N048YCI             TTPC    TTOF1A 289171092679389OOLU 1562340 TPM 641  KT$YES  20120830000156KK 12012301??????000011YGY, 91|TTT232MC00640      TTT232    TTAC1YOOLU 1562340 Y      0
2012-08-30 00:23:57, 2012-08-30 00:23:59, TTOF1B, TTAC1, 2.183,TTT232MM0N078YCI             TTPC    TTOF1B 289171092683100TCLU 3192440 TPM 469  KT$YES  20120830002357KK 12012302??????000011YGY, 91|TTT232MC00649      TTT232    TTAC1YTCLU 3192440 Y      0


Last edited by ment0smintz; 10-09-2012 at 01:54 AM..
# 2  
Old 10-08-2012
whats the desired output? could you also post the code you have tried for this?
# 3  
Old 10-09-2012
I am still new and I havent done much so...
Code:
touch /tmp/result4_file // create 2 files
touch /tmp/result5_file 
 
while read myRecord;do
case $myRecord in
*)
     echo "$myRecord" > /tmp/result4_file
     datetime_yc=`cat /tmp/result4_file | cut -c1-19`
        ;;
        esac
echo "$datetime_yc" >> /tmp/result5_file
done < /tmp/yclogs

I will still work on it thou... will be applying cut to catch the patten format
# 4  
Old 10-09-2012
ur output: 2012-08-30 00:01:58,577 - 2012-08-30 00:01:56,554 2.23

we can do it using awk, since it is ',' delimited file
Code:
awk -F',' '{print $1"-"$2"  "$5}' filename >> newfilename


Last edited by Franklin52; 10-09-2012 at 05:46 AM.. Reason: Please use code tags for data and code samples
# 5  
Old 10-09-2012
Code:
the format now is:
 
a1 ---- ----- ----- -----
b1 ---- ----- ----- -----
a2 ---- ----- ----- -----
b2 ---- ----- ----- ----- 
a3 ---- ----- ----- -----
b3 ---- ----- ----- -----
a4 ---- ----- ----- -----
*a4 ---- ----- ----- -----
b4 ---- ----- ----- -----

pattern for output is

Code:
a1,b1, extract data from both fields.....
a2,b2, extract data from both fields.....
a3, b3, extract data from both fields....
*a4,b4, extract data from both fields...

# 6  
Old 10-09-2012
something like this...

Code:
awk '{if(!(NR%2)){p=$1;gsub(p,"",$0);for(x in a){print s,p,$0,a[x];delete a[x]}}
else{s=$1;gsub(s,"",$0);a[s]=$0}}' file

# 7  
Old 10-09-2012
Quote:
Originally Posted by pamu
something like this...

Code:
awk '{if(!(NR%2)){p=$1;gsub(p,"",$0);for(x in a){print s,p,$0,a[x];delete a[x]}}
else{s=$1;gsub(s,"",$0);a[s]=$0}}' file

can further explain to me in logic format.. cant decrypt most of it
i understand NR%2 is number of records mod 2 {p=$1; then everything looks so blur.....

Code:
awk: syntax error near line 1
awk: illegal statement near line 1
awk: syntax error near line 1
awk: illegal statement near line 1
awk: syntax error near line 2
awk: bailing out near line 2


Last edited by ment0smintz; 10-09-2012 at 06:51 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

How to parse .nessus file to get result in human readable format?

Scripting Language: bash shell script, python I want to parse .nessus file in human readable format. If any one have any ideas please help me. (2 Replies)
Discussion started by: sk151993
2 Replies

2. Shell Programming and Scripting

Script to generate Excel file or to SQL output data to Excel format/tabular format

Hi , i am generating some data by firing sql query with connecting to the database by my solaris box. The below one should be the header line of my excel ,here its coming in separate row. TO_CHAR(C. CURR_EMP_NO ---------- --------------- LST_NM... (6 Replies)
Discussion started by: dani1234
6 Replies

3. UNIX for Advanced & Expert Users

How to export Result to Excel Tabular format from UNIX?

Hi I am working on a script in which I am firing a query on database through Unix and getting the result set. I want to export that in an excel file. I am able to do so nut the result are exported horizontally one below the other. Can anyone plss help me out in exporting the Result in Tabular... (4 Replies)
Discussion started by: Saritau3
4 Replies

4. Shell Programming and Scripting

Different cmd to execute and based on some pattern parse it and then store result in xlx format

Hi I have a different requirement, I need to run some application on my device from a file app_name.txt one by one which is like this: /usr/apps/email /usr/apps/message /usr/apps/settings after each app while it is running I need to execute again one cmd like ps -ef |grep... (2 Replies)
Discussion started by: Sanjeev Roy
2 Replies

5. UNIX for Dummies Questions & Answers

Preserving the format of top command result

hi, I have tried the below command in RHEL5: top|mailx -s "test" "abc@cvf.com" But in the mail the content was not in proper format. Is there any way to preserve the format ? Thanks (2 Replies)
Discussion started by: pandeesh
2 Replies

6. Shell Programming and Scripting

Help with perl script to output data in table format...

Hello, I need help with a perl script that will process a text file and match virtual server name to profile(s). the rest will be ignored. Virtual server name follows the word "virtual" in the begging of the line. There could be multiple profiles assigned to one virtual server. For example, ... (3 Replies)
Discussion started by: besogon
3 Replies

7. Shell Programming and Scripting

How to format sql result as amount - ksh

I am currently returning an sql result with a number value that I want to format as an amount. The sql runs smoothly on its own, but when run inside my ksh script an error is encountered: ERROR at line 3: ORA-01481: invalid number format model My sql is -- select distinct ... (6 Replies)
Discussion started by: avillanueva
6 Replies

8. Shell Programming and Scripting

How to Format the result driven from a SQL Query

Hi All, I want to format the result driven from the query into neat format. For example pls find the below code, #! /bin/sh result=' sqlplus -s uname/passwrd@DBname select no,name,address,ph_no, passport_no,salary,designation from emp_table where salary>1000; exit EOF' ... (8 Replies)
Discussion started by: little_wonder
8 Replies

9. UNIX for Dummies Questions & Answers

converting a tabular format data to comma seperated data in KSH

Hi, Could anyone help me in changing a tabular format output to comma seperated file pls in K-sh. Its very urgent. E.g : username empid ------------------------ sri 123 to username,empid sri,123 Thanks, Hema:confused: (2 Replies)
Discussion started by: Hemamalini
2 Replies

10. UNIX for Dummies Questions & Answers

kstat - format of output data?

Hi, I am looking for a cpu usage data (%usr, %iowait, %idle, %kernel) using kstat. The output of kstat is below. How do I interpret those numeric values? In other words, how do I calculate the percentage value using the values below? Thanks a lot! Ozvena module: cpu_stat ... (4 Replies)
Discussion started by: ozvena
4 Replies
Login or Register to Ask a Question