I have 5 column in sample txt file
where in i have to create report based upon 1,3 and 5 th column..
I have : in first and third coulmn. But I want to retain the colon of fifth coulmn and remove the colon of first column..
5th column contains String message (for example, $5=string1:string2:String3)
and 1st column contains full path of script execution (for example, $1=path:MM/DD/YYYY HH:MM:SS ) As I have to extract path from $1 I have given awk -F':|] ' ' but checks for all colon every line.
Can anyone please guide me how to remove : from $1 only.
Thanks in advance.
Here is the command which i formed working properly. But the problem occurs when My Messages is having colon in it. Only part of message gets displayed (the part after : that only Message3 displayed)
My output looks like:
,Filename,Error Message,Count
cat sample.txt | awk -F':|] ' '/ERROR|INFO/{ split($1,fn,"/");
for (i in fn)
if(fn~/^snow|^thunder/) {
ind=i
strval=fn[ind]
sub(".*/"strval"/","",$1)
val=strval","$1
}
if (fn !~ /^snow|^thunder/) {
sub(".*/","",$1)
OFS=","
val=strval","$1
}
a[val OFS $NF]++
}
END{for(j in a)print j,a[j]}'| sort -k1,3
Content of sample.txt
/mylogsfolderpath/logs/nrf*Log20100930.log/09/30/2010/12:10:04 INFO [UNKNOWN] INFO Message.
/mylogsfolderpath/logs/nrf*220100929.log/09/29/2010/11:35:16 ERROR [12857745252700] Error Message
/mylogsfolderpath/logs/nrf*220100928.log/09/29/2010/11:45:16 ERROR [12857745652700] Error Message1:Message2:Message3