I run a command,(EMC Celerra replication status), and it prints in specific format. I would like to re-format to read better. Any help is appreciated.
FROM:
Name = Job1
Last Sync Time = Mon Aug 22 16:38:32 EDT 2011
Name = Job2
Last Sync Time = Mon Aug 22 16:38:32 EDT 2011
Name = Job3
Last Sync Time = Mon Aug 22 16:38:32 EDT 2011
Name = Job4
TO:
Name Last Sync Time
Job1 Mon Aug 22 16:38:32 EDT 2011
Job2 Mon Aug 22 16:38:32 EDT 2011
Job3 Mon Aug 22 16:38:32 EDT 2011
Job4 Mon Aug 22 16:38:32 EDT 2011
$ cat infile
Name = Job1
Last Sync Time = Mon Aug 22 16:38:32 EDT 2011
Name = Job2
Last Sync Time = Mon Aug 22 16:38:32 EDT 2011
Name = Job3
Last Sync Time = Mon Aug 22 16:38:32 EDT 2011
Name = Job4
$ cat script.pl
use warnings;
use strict;
use autodie;
my @data;
@ARGV == 1 or die qq(Usage: perl $0 file\n);
while ( <> ) {
chomp;
my @f = split /\s*=\s*/;
printf "%s " . ( ($. == 2) ? "\n" : "" ), $f[0] if $. <= 2;
push @data, $f[1];
if ( $. % 2 == 0 ) {
printf "%s\n", "@data";
@data = ();
}
}
$ perl script.pl infile
Name Last Sync Time
Job1 Mon Aug 22 16:38:32 EDT 2011
Job2 Mon Aug 22 16:38:32 EDT 2011
Job3 Mon Aug 22 16:38:32 EDT 2011
If im not wrong, doesn't the above solutions' output start with same column as you required.. the sed,perl or awk solution..? Please re-check on Perl or Sed solution.
Right now, with all the solutions, output is like this.
Name Last Sync Time
Job1 Thu Aug 25 11:00:17 EDT 2011
Job2 Thu Aug 25 11:00:17 EDT 2011
Job3 Thu Aug 25 11:00:17 EDT 2011
Job4 Thu Aug 25 11:00:17 EDT 2011
I just want the "Last Sync Time" to start the same column.