awk '{n=n+NF} n>1000 {print ":"NR; exit}' That will print something you can plumb and go to the line you want.
Should be obvious enough how to generalize into a reusable script. (Typed from memory and not tested.) uriel On Tue, Mar 3, 2009 at 4:40 PM, roger peppe <rogpe...@gmail.com> wrote: > 2009/3/3 Rudolf Sykora <rudolf.syk...@gmail.com>: >>> I would do it with awk myself, Much depends on what you want to >>> do to the 1000'th word on the line. >> >> Say I really want to get there, so that I can manually edit the place. > > if i really had to do this (as a one-off), i'd probably do it in a > few stages: > > copy & paste the line to a New blank window. > in the new window: > Edit ,x/[ ]+/a/\n/ > :1000 > > edit as desired > Edit ,x/\n/d > > copy and paste back to the original window. > > if you were going to do this a lot, you could easily make a little > script to tell you the offset of the 1000th word. > > e.g. > sed 's/[ \t]+/&\n/' | sed 1000q | tr -d '\012' | wc -c > > actually that doesn't work 'cos sed has line length issues. > so i'd probably do it in C - the program would take the line > as stdin and could print out address > of the word in acme-friendly notation, e.g. :-++#8499;+#6 > > it'd only be a few minutes to write. > > another option would be to write a little script that used the > addr file repeatedly to find the nth match of a regexp. > >