In AWK, is there a way to print all columns? I do not want to print them like this:

printf($1 $2 $3 ...)

Is there a way to print all of them?


This will print all:

awk '{print $0}'    

And to make this long enough: this will print columns 3 to 6:

awk -v f=3 -v t=6 '{for(i=f;i<=t;i++) printf("%s%s",$i,(i==t)?"\n":OFS)}'

OFS is a built-in variable (there are 8: FS, OFS, RS, ORS, NR, NF, FILENAME, FNR) and is the output field seperator (more here).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.