What about using $0 (whole line) and
length($1),length($2),length($3) and substr($0,sumoflengths)

or something like that ?

Pete

CF wrote:
On Tue, 2003-10-07 at 17:49, Tom Munro Glass wrote:

I'm trying to parse a log file, very similar to /var/log/messages, where there are some quite well defined fields at the start of the line, but then some free form text at the end. I can extract and process the first few fields quite easily with $1 $2 $3 etc, but how can I get awk to print out the rest of the line after field $3 and ignore any delimiter characters in the free from text?

For example, consider the input

01/10/2003 01:02:03 MyCommand: Here is some free form text from command

When parsed with awk:

$1 = date (01/10/2003)
$2 = time (01:02:03)
$3 = command (MyCommand:)
?? = Here is some free form text from command

Any ideas?


Its not a good answer, but
echo "01/10/2003 01:02:03 MyCommand: Here is some free form text from
command" | awk '{ print $3 " " $4 " " $5 " " $6 " " $7 " " $8 " " $9 " "
$10 " " $11 ........ }'

would do the trick.  Or someone else will suggest Python or Perl or
$languageofchoice.

I don't think you can do a ' { print $4- } ' in awk




-- ------------------------------------------------------------------- - I N V E S T I N A L L U N I V E R S I T Y S T A F F - ------------------------------------------------------------------- Peter Glassenbury Computer Science dept. [EMAIL PROTECTED] University of Canterbury +64 3 3642987 ext 7762 New Zealand



Reply via email to