poask
Technical User
- Feb 14, 2008
- 2
Hi,
I'm trying to use awk for the first time to do some calculations on some log files with non-standard timestamps, like these:
14:12:25.612
14:14:18.272
14:17:54.491
The first thing I want is to split each of the values for hours, minutes, seconds, milliseconds but I can't find a separator field that works. (Also there is more info on the same lines as the timestamps that I want to extract.)
I need to be able to specify a space, colon, and period as separators.
I tried
awk 'BEGIN {FS = ".: "}; {print $1":"$2":"$3"."$4}' 2.txt
but as soon as the period is not the only character in the FS field it is treated as a wildcard match in a regular expression.
I tried
awk 'BEGIN {FS = "\.: "}; {print $1":"$2":"$3"."$4}' 2.txt
but the following warning appears and it doesn't work again
awk: cmd. line:1: warning: escape sequence `\.' treated as
plain `.'
It must be something very simple and basic that I'm missing but it's very frustrating...
Anyone have a suggestion?
Many thanks,
Cheers
I'm trying to use awk for the first time to do some calculations on some log files with non-standard timestamps, like these:
14:12:25.612
14:14:18.272
14:17:54.491
The first thing I want is to split each of the values for hours, minutes, seconds, milliseconds but I can't find a separator field that works. (Also there is more info on the same lines as the timestamps that I want to extract.)
I need to be able to specify a space, colon, and period as separators.
I tried
awk 'BEGIN {FS = ".: "}; {print $1":"$2":"$3"."$4}' 2.txt
but as soon as the period is not the only character in the FS field it is treated as a wildcard match in a regular expression.
I tried
awk 'BEGIN {FS = "\.: "}; {print $1":"$2":"$3"."$4}' 2.txt
but the following warning appears and it doesn't work again
awk: cmd. line:1: warning: escape sequence `\.' treated as
plain `.'
It must be something very simple and basic that I'm missing but it's very frustrating...
Anyone have a suggestion?
Many thanks,
Cheers