Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi, I have following data format:
A : ABC
Model: v3.5.8
source: C:\data\ABC.raw
B : 123
C : 2000-10-28
D : 05:17
E : 2000-11-08
F : 01:15
name: scott tiger
Purpose: Production
P_id: 213435
Class: Normal
G_id: 1828G
SS (m): 1008W x 859H
SI (m): 16.000
SC (m): 15.000
ST (m): 0.500
NFZ: 4
Vstd: EF098
VC: 0.885
CE: 0.881
Notes: None
G H I J K L(1/m) M(n/m/m) N(n)XYZ efg 10.04 0.123 N 0.52 0 0
XYZ hijk 123.15 0.456 N 0.24 0 0
XYZ lmn 1001.50 0.789 N 0.88 0 0
XYZ opq 1102.20 0.147 N 0.35 0 0
....
I need to convert above data as following format which will be recognized by oracle sql*loader.ABC 123 2000-10-28 05:17 2000-11-08 01:15 XYZ efg 10.04 0.123 N 0.52 0 0
ABC 123 2000-10-28 05:17 2000-11-08 01:15 XYZ hijk 123.15 0.456 N 0.24 0 0
ABC 123 2000-10-28 05:17 2000-11-08 01:15 XYZ lmn 1001.50 0.789 N 0.88 0 0
ABC 123 2000-10-28 05:17 2000-11-08 01:15 XYZ opq 1102.20 0.147 N 0.35 0 0
.........How to write a shell script to do the job? Thanks.

#! /usr/bin/perl
open( FD, "< data" ) or die "cannot open data";
foreach ( <FD> ) {
if ( /^A : / ) {
( $val ) = /.*: (.*)$/;
next;
}
if ( /^B : / or /^C : / or /^D : / or /^E : / or /^F : / or /^C : / ) {
( $n_val ) = /.*: (.*)$/;
$val = $val." ".$n_val;
next;
}
if ( /^XYZ/ ) {
print $val." ".$_;
}
}
0;

![]() |
grep file for key in loop...
|
Solaris 8 - linksys DHCP ...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |