Hi
I have log like this :
And i want the log become like this :
can somebody help me??
Hi
I have log like this :
And i want the log become like this :
can somebody help me??
awk '{ print $1, $2, $3, (NR==1 ? "Type" : "Stream1"), $4, $5, $6, $7}' inputfile
Jean-Pierre.
Hello Jean..
I think you forget about the Date, and Time also different.
Rgds,
Bow
awk '
NR == 1 { print "Date Time Object Type A B C D" }
NR != 1 { print $1, int(NR/2) - 1, $3,"Stream1",$4,$5,$6,$7}
' infile > outfile
Hello fpmurphy,
looks like correct..but the date column is same value..
Rgrds,
Bow
A solution with gawk :
Assume new date/time = date/time + 8 hours.
awk '
BEGIN {
h8 = 8*3600;
}
NR==1 {
print $1,$2,$3,"Type",$4,$5,$6,$7;
next;
}
{
date=$1 " " $2 " " 00;
gsub(/[\-:]/, " ", date);
timestamp = mktime(date)+h8;
new_date = strftime("%Y-%m-%d", timestamp);
new_time = strftime("%H", timestamp)+0;
print new_date,new_time,$3,"Stream1",$4,$5,$6,$7;
}
' inputfile
Jean-Pierre.