In AWK, is it possible to specify "ranges" of fields?

Solution 1:

Besides the awk answer by @Jerry, there are other alternatives:

Using cut (assumes tab delimiter by default):

cut -f32-58 foo >bar

Using perl:

perl -nle '@a=split;print join "\t", @a[31..57]' foo >bar

Solution 2:

Mildly revised version:

BEGIN { s = 32; e = 57; }

      { for (i=s; i<=e; i++) printf("%s%s", $(i), i<e ? OFS : "\n"); }