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



Reply via email to