On 17/01/18 06:16, Peng Yu wrote: > Hi, > > If there is only one column in the input, then an out-of-range field > spec will result in the print of the whole line. > > $ cut -f 3 <<< $'a' | xxd > 0000000: 610a a. > > Otherwise, an empty string is printed. > > $ cut -f 3 <<< $'a\tb' | xxd > 0000000: 0a . > > This is counter-intuitive. I think that one-field input should not be > treated specially. It should still result in no output for an > out-of-range field spec. > > Is there a strong reason why `cut` should treat one-field input > different? (What if users do want empty string be printed for > out-of-range field even for one-field input?) Or this should be > considered as a bug?
It's expected albeit confusing behavior, documented at: http://www.pixelbeat.org/docs/coreutils-gotchas.html#cut Essentially cut passes lines without delimiters through unchanged by default cheers, Pádraig.
