Hi,
Does anyone know a easy way to printf $3,$4, ... all the way to the last field in the file? I will need to modify $1 and $2 and then printf modified $1 and $2 and the rest of the fields(which are not changed).
I know I can use NF as the total number of field.
Do I use a for next statement to loop through?
Thank you for your reply.
The things is everytime the file that passed to awk is different.
So I don't know the exact number of columns.
But I only modify $1,$2. There might be over 10 fields after that.
It's really $0 - $1 - $2.
I need to write out any fields after $1 and $2.
I know it's been over a year, but maybe someone else will benefit from this.
If you want to print everything but a number of fields, set them to "" (null)
So, to print everything past $2, type:
awk '{ $1=""; $2=""; print $0}' foo.log
This can be shortened to:
awk '{ $1=$2=""; print $0}' foo.log
Be sure never to set $0 to null, because that will nuke your entire string.:o