#############################################################################################################
19/Apr/2010:07:06:19 "Changed directory to dms-imrm/Fort_Wayne/Parkview" - SUCCESSFUL
19/Apr/2010:07:06:19 "Changed directory to Requisitions" - SUCCESSFUL
19/Apr/2010:07:06:21 "Deleted 668027.ZIP" - FAILED
19/Apr/2010:07:06:23 "Uploaded 668027.ZIP" ---- FILE SIZE(Bytes) :5583273
#############################################################################################################
I have a sample file like above which I got from a log file with the help of script.
Can anybody help me in re-formatiing it into
#############################################################################################################
19/Apr/2010:07:05:50 dms-imrm/Fort_Wayne/Parkview/Requisitions Deleted 668027.ZIP FAILED 0
19/Apr/2010:07:05:57 dms-imrm/Fort_Wayne/Parkview/Requisitions Uploaded 668027.ZIP SUCCESSFUL 5583273
#############################################################################################################
Scott
April 28, 2010, 8:52am
2
tuxidow:
#############################################################################################################
19/Apr/2010:07:06:19 "Changed directory to dms-imrm/Fort_Wayne/Parkview" - SUCCESSFUL
19/Apr/2010:07:06:19 "Changed directory to Requisitions" - SUCCESSFUL
19/Apr/2010:07:06:21 "Deleted 668027.ZIP" - FAILED
19/Apr/2010:07:06:23 "Uploaded 668027.ZIP" ---- FILE SIZE(Bytes) :5583273
#############################################################################################################
I have a sample file like above which I got from a log file with the help of script.
Can anybody help me in re-formatiing it into
#############################################################################################################
19/Apr/2010:07:06:19 "Changed directory to dms-imrm/Fort_Wayne/Parkview" - SUCCESSFUL
19/Apr/2010:07:06:19 "Changed directory to Requisitions" - SUCCESSFUL
19/Apr/2010:07:06:21 "Deleted 668027.ZIP" - FAILED
19/Apr/2010:07:06:23 "Uploaded 668027.ZIP" ---- FILE SIZE(Bytes) :5583273
#############################################################################################################
Hi.
My eyes may be playing tricks, but they look the same
Hi,
What is the difference between above two files.
I know one magic UNIX command - it's called 'cp'
What's the diff between the 2 files?
Sorry
#############################################################################################################
19/Apr/2010:07:05:50 dms-imrm/Fort_Wayne/Parkview/Requisitions Deleted 668027.ZIP FAILED 0
19/Apr/2010:07:05:57 dms-imrm/Fort_Wayne/Parkview/Requisitions Uploaded 668027.ZIP SUCCESSFUL 5583273
#############################################################################################################
aigles
April 28, 2010, 10:45am
6
Try the following AWK program :
#!/usr/bin/awk -f
BEGIN {
FS = "[\" :]+";
}
{
sub(FS "$", "");
Action = $5;
ActionLower = tolower($5);
if (ActionLower == "changed") {
if (ResetPath) Path = "";
ResetPath = 0;
Path = (Path ? Path "/" : "") $8;
next;
}
ResetPath = 1;
if (ActionLower == "deleted") {
File = $6;
Status = $NF;
print $1,Path,Action,File,"-",Status
next;
}
if (ActionLower == "uploaded") {
File = $6;
Status = $NF;
if (Status ~ /^[0-9]+$/) Status = "SUCCESSFUL " Status;
print $1,Path,Action,File,"-",Status
next;
}
}
Output:
19/Apr/2010 dms-imrm/Fort_Wayne/Parkview/Requisitions Deleted 668027.ZIP - FAILED
19/Apr/2010 dms-imrm/Fort_Wayne/Parkview/Requisitions Uploaded 668027.ZIP - SUCCESSFUL 5583273
Jean-Pierre.
excellent!! thanks a lot... no ton...
only thing which i am missing is the time stamp. Im trying to fix it..
---------- Post updated at 08:24 AM ---------- Previous update was at 07:40 AM ----------
I could not get the time stamp included. Can you please help me in that..?
like 19/Apr/2010:07:05:50 dms-imrm/Fort_Wayne/Parkview/Requisitions Deleted 668027.ZIP - FAILED
aigles
April 28, 2010, 1:24pm
8
#!/usr/bin/awk -f
BEGIN {
FS = "[\" :]+";
}
{
sub(FS "$", "");
DateTime = $1 ":" $2 ":" $3 ":" $4;
Action = $5;
ActionLower = tolower($5);
if (ActionLower == "changed") {
if (ResetPath) Path = "";
ResetPath = 0;
Path = (Path ? Path "/" : "") $8;
next;
}
ResetPath = 1;
if (ActionLower == "deleted") {
File = $6;
Status = $NF;
print DateTime,Path,Action,File,"-",Status
next;
}
if (ActionLower == "uploaded") {
File = $6;
Status = $NF;
if (Status ~ /^[0-9]+$/) Status = "SUCCESSFUL " Status;
print DateTime,Path,Action,File,"-",Status
next;
}
}
Jean-Pierre.
1 Like
Excellent!!! Thanks a lot again.....
I need one more help in this.. Can you please help me in that..
#############################################################################################################
19/Apr/2010:07:06:19 "Changed directory to dms-imrm/Fort_Wayne/Parkview" - SUCCESSFUL
19/Apr/2010:07:06:19 "Changed directory to Requisitions" - SUCCESSFUL
19/Apr/2010:07:06:21 "Deleted 668027 axxxx1.ZIP" - FAILED
19/Apr/2010:07:06:23 "Uploaded 668027 axxxx2.ZIP" ---- FILE SIZE(Bytes) :5583273
#############################################################################################################
if I have a space in the file name as above this script is not taking the file name fully instead the first field only ie 668027 . yeah i know that the logic you are using is bit different in this case. Can you please help me in resolving that?
curleb
April 29, 2010, 11:07am
10
assuming the actual file name will always be the next "word" in the sequence, you'd want to also define a name-type variable using $7.
aigles
April 29, 2010, 11:13am
11
Try this new version :
#!/usr/bin/awk -f
BEGIN {
FS = "[\" :]+";
}
{
sub(FS "$", "");
DateTime = $1 ":" $2 ":" $3 ":" $4;
Action = $5;
ActionLower = tolower($5);
if (ActionLower == "changed") {
if (ResetPath) Path = "";
ResetPath = 0;
Path = (Path ? Path "/" : "") $8;
next;
}
ResetPath = 1;
if (ActionLower == "deleted") {
File = $0;
sub(".*\"" Action " *", "", File);
sub("\".*", "", File);
Status = $NF;
print DateTime,Path,Action,File,"-",Status
next;
}
if (ActionLower == "uploaded") {
File = $0;
sub(".*\"" Action " *", "", File);
sub("\".*", "", File);
Status = $NF;
if (Status ~ /^[0-9]+$/) Status = "SUCCESSFUL " Status;
print DateTime,Path,Action,File,"-",Status
next;
}
}
Input file:
19/Apr/2010:07:06:19 "Changed directory to dms-imrm/Fort_Wayne/Parkview" - SUCCESSFUL
19/Apr/2010:07:06:19 "Changed directory to Requisitions" - SUCCESSFUL
19/Apr/2010:07:06:21 "Deleted 668027.ZIP" - FAILED
19/Apr/2010:07:06:23 "Uploaded 668027.ZIP" ---- FILE SIZE(Bytes) :5583273
20/Apr/2010:07:06:19 "Changed directory to dms-imrm/Fort_Wayne/Parkview" - SUCCESSFUL
20/Apr/2010:07:06:19 "Changed directory to Requisitions-2" - SUCCESSFUL
20/Apr/2010:07:06:21 "Deleted 668027 axxxx1.ZIP" - FAILED
20/Apr/2010:07:06:23 "Uploaded 668027 axxxx2.ZIP" ---- FILE SIZE(Bytes) :5583273
Output:
19/Apr/2010:07:06:21 dms-imrm/Fort_Wayne/Parkview/Requisitions Deleted 668027.ZIP - FAILED
19/Apr/2010:07:06:23 dms-imrm/Fort_Wayne/Parkview/Requisitions Uploaded 668027.ZIP - SUCCESSFUL 5583273
20/Apr/2010:07:06:21 dms-imrm/Fort_Wayne/Parkview/Requisitions-2 Deleted 668027 axxxx1.ZIP - FAILED
20/Apr/2010:07:06:23 dms-imrm/Fort_Wayne/Parkview/Requisitions-2 Uploaded 668027 axxxx2.ZIP - SUCCESSFUL 5583273
Jean-Pierre.
aigles:
Try the following AWK program :
#!/usr/bin/awk -f
BEGIN {
FS = "[\" :]+";
}
{
sub(FS "$", "");
Action = $5;
ActionLower = tolower($5);
if (ActionLower == "changed") {
if (ResetPath) Path = "";
ResetPath = 0;
Path = (Path ? Path "/" : "") $8;
next;
}
ResetPath = 1;
if (ActionLower == "deleted") {
File = $6;
Status = $NF;
print $1,Path,Action,File,"-",Status
next;
}
if (ActionLower == "uploaded") {
File = $6;
Status = $NF;
if (Status ~ /^[0-9]+$/) Status = "SUCCESSFUL " Status;
print $1,Path,Action,File,"-",Status
next;
}
}
Output:
19/Apr/2010 dms-imrm/Fort_Wayne/Parkview/Requisitions Deleted 668027.ZIP - FAILED
19/Apr/2010 dms-imrm/Fort_Wayne/Parkview/Requisitions Uploaded 668027.ZIP - SUCCESSFUL 5583273
Jean-Pierre.
One more question...
How can i keep the ################## there?
#############################################################################################################
19/Apr/2010:07:05:50 dms-imrm/Fort_Wayne/Parkview/Requisitions Deleted 668027.ZIP FAILED 0
19/Apr/2010:07:05:57 dms-imrm/Fort_Wayne/Parkview/Requisitions Uploaded 668027.ZIP SUCCESSFUL 5583273
#############################################################################################################
aigles
May 13, 2010, 10:13am
14
tuxidow:
One more question...
How can i keep the ################## there?
#############################################################################################################
19/Apr/2010:07:05:50 dms-imrm/Fort_Wayne/Parkview/Requisitions Deleted 668027.ZIP FAILED 0
19/Apr/2010:07:05:57 dms-imrm/Fort_Wayne/Parkview/Requisitions Uploaded 668027.ZIP SUCCESSFUL 5583273
#############################################################################################################
#!/usr/bin/awk -f
BEGIN {
FS = "[\" :]+";
}
/^#+/ {
print;
next;
}
{
sub(FS "$", "");
Action = $5;
. . . . .
Jean-Pierre.