Select all the even columns from a file

Hi,

I can select all the even columns from a file like this:

awk '{ for (i=1;i<=NF;i+=2) $i="" }1' file > new file

How can I select the 1st and all the even columns using awk? Thanks!

Please use code tags for code.

Change i=1 into i=3 and it will leave the first column intact.

1 Like