1

I'm learning about the cut command. In the man page of cut, they show the -n option like:

-n     (ignored)

But I didn't understand the usage of the n option or when we would use it. Can anyone explain with an example?

3

Your man cut describes -n option as "ignored", simply because it is not implemented, in the cut implementation from coreutils.

However, the -n option is implemented on some others cut implementations, at least in the *BSD \ POSIX.2 implementation(s).

Thus 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.

From 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.

  • An example of how to use would be even more useful. I tried using it with the -b flag, but can't really figure out how it is used – Inian Aug 6 '19 at 10:46
  • @Inian the post is more about not using it... – Rui F Ribeiro Aug 6 '19 at 11:03
  • The Question did mention "Can any one explain with example?"... – Jeff Schaller Aug 6 '19 at 12:56
  • @JeffSchaller It did assuming it had some kind of useful in the concerned implementation, which does not have... I might expand it for use in other systems, when I have the time. Work day here. – Rui F Ribeiro Aug 6 '19 at 13:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.