== An irritating _awk_ limitation: getting a range of fields Writing things in _awk_ has a number of little irritations that come up every so often. One of them is that it has no built in way to retrieve a range of input fields as a string, ie there is no equivalent of what in Python one could write as something like '_r = " ".join(input[2:])_' (which turns everything from the third field onwards back into a single string). Of course, you can do this with an awk function. But it's irritating to have to keep including that function in my _awk_ programs (especially when they are tiny programs that are written inline in a larger shell script), and it points out a deeper weakness in _awk_, which is that _awk_ has no really good way to manipulate how lines are split into fields. Take the example from [[yesterday ../unix/ForcingSortOrder]] and consider the _sed_ invocation, which only exists because of this _awk_ issue. What we really want to do is split each line into two fields: the first word of the line, and then everything else; then we will print the second field and ignore the first one. However, you can't do this in _awk_ (or at least not very easily). (To beat people to the obvious approach: yes, you can assign an empty string to _$1_ and then use _$0_, but that puts a space at the front of the new _$0_, which is sometimes important.) === Sidebar: the necessary awk function Here's the necessary awk function: > function fieldstr(s, e, i, r) { > if (e > NF) e = NF > r = $(s) > for (i = s+1; i <= e; i++) > r = r " " $(i) > return r > } With no error checking, you can make this a sensible one-liner function body without being too offensive. (In my version I put the '_return r_' on a second line because otherwise it looked too crammed in.)