I'm learning about the
cut command. In the man page of cut, they show the
-n option like:
But I didn't understand the usage of the
n option or when we would use it. Can anyone explain with an example?
man cut describes -n option as "ignored", simply because it is not implemented, in the
cut implementation from
However, the -n option is implemented on some others
cut implementations, at least in the *BSD \ POSIX.2 implementation(s).
cut from coreutils implements a stub option to it, for portability sake, for not breaking compatibility with scripts. However, as it is not implemented, it won't have any effect using it.
man cut in FreeBSD 12.0:
-n Do not split multi-byte characters. Characters will only be output if at least one byte is selected, and, after a prefix of zero or more unselected bytes, the rest of the bytes that form the character are selected.
From the POSIX standard
cut page, link pointed out by @Kusalananda:
-n Do not split characters. When specified with the -b option, each element in list of the form low- high ( -separated numbers) shall be modified as follows:
If the byte selected by low is not the first byte of a character, low shall be decremented to select the first byte of the character originally selected by low. If the byte selected by high is not the last byte of a character, high shall be decremented to select the last byte of the character prior to the character originally selected by high, or zero if there is no prior character. If the resulting range element has high equal to zero or low greater than high, the list element shall be dropped from list for that input line without causing an error.
Each element in list of the form low- shall be treated as above with high set to the number of bytes in the current line, not including the terminating . Each element in list of the form - high shall be treated as above with low set to 1. Each element in list of the form num (a single number) shall be treated as above with low set to num and high set to num.