Hacker News new | ask | show | jobs
by pimlottc 1468 days ago
What do you mean by negative indexes?
1 comments

I believe "negative index" means array[-1] is the last element in array, array[-2] is the second-to-last element, etc.

In the context of "cut", it would mean being able to do something like:

cut -d" " -f1--2

the "-f1--2" (read: fields from 1 to minus 2; it's a range) means to select from the first field to the second-to-last field. (that double "--" is pretty awkward, to be sure!)

Some programming languages (ruby is the one that I know) have this feature for accessing array elements.