4 ms·
I'll take this opportunity to bash the Unix "tail" utility. "tail -c +n" is supposed to mean "print all characters (or bytes, rather), starting at index n". U
by waterhouse 15y ago
I'll take this opportunity to bash the Unix "tail" utility. "tail -c +n" is supposed to mean "print all characters (or bytes, rather), starting at index n". Unfortunately, the implementer used 1-origin indexing, which is bad enough when I expect 0-origin. But there's also a clear alternative semantics that doesn't even use the concept of indexing: "tail -c +n" should mean "exclude the first n bytes". Both interpretations lead me to expect the following command to output "56789", but it doesn't, and I have been burned twice already by off-by-one errors due to this:
$ echo '0123456789' | tail -c +5
456789
- veyron 15y agoI am sympathetic to your desires, but the man page clearly states the implemented behavior: $ tail --version | head -n 1 tail (GNU coreutils) 8.5 $ man tail | grep -A 2 bytes=K -c, --bytes=K output the last K bytes; alternatively, use -c +K to output bytes starting with the Kth of each file The fifth byte of '0123456789' is the byte corresponding to '4', and the manpage says it will output bytes starting with the 5th (ie 456789)