asak
1
Hi,
i need a perl script which reads the file, content is given below. and output in new file.
TARGET DRIVE IO1 IO2 IO3 IO4 IO5
------------ --------- --------- --------- --------- ---------
0a.1.8 266 236 179 607 337
0a.1.7 232 202 147 504 262
0a.1.13 257 231 175 611 319
0a.1.12 256 227 168 603 323
i need output in new file in following format.
TARGETDRIVE : 0a.1.8 0a.1.7 ......
IO1 = 266 232 257 256
IO2 = 236 202 231 227
IO3 = 179 147 175 168
:
:
so on
Thanks,
asak
$
$
$ cat f23
TARGET DRIVE IO1 IO2 IO3 IO4 IO5
------------ --------- --------- --------- --------- ---------
0a.1.8 266 236 179 607 337
0a.1.7 232 202 147 504 262
0a.1.13 257 231 175 611 319
0a.1.12 256 227 168 603 323
$
$
$
$ perl -lane 'if ($. == 1) {
push @{$x[0]}, "$F[0]$F[1] :";
for ($i=2; $i<=$#F; $i++) {push @{$x[$i-1]}, "$F[$i] ="}
} elsif (!/-/) {
for ($i=0; $i<=$#F; $i++) {push @{$x[$i]}, $F[$i]}
}
END {
for ($i=0; $i<=$#x; $i++) {print "@{$x[$i]}"}
}
' f23
TARGETDRIVE : 0a.1.8 0a.1.7 0a.1.13 0a.1.12
IO1 = 266 232 257 256
IO2 = 236 202 231 227
IO3 = 179 147 175 168
IO4 = 607 504 611 603
IO5 = 337 262 319 323
$
$
$
tyler_durden
1 Like
asak
3
Hi tyler,
i did'nt get your code, can you please explain,
Regards,
asak
It simply creates and prints an array, each element of which is a reference to an array of columnar data.
tyler_durden
1 Like