Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

another FS question

Status
Not open for further replies.

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
 
What about this ?
FS = "[.: ]+"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top