Для чего используется параметр n в команде cut?

Пробовали ли вы сделать файл resolv.conf неизменяемым после добавления любого содержимого?.

Вы можете использовать chattr +i /etc/resolv.confили с sudo.

Делая это, мы избегаем перезаписи.

Если он не будет удален, он может дать первоначальную информацию.

1
06.08.2019, 15:57
1 ответ

Ваш man cutописывает параметр -n как "игнорируемый" просто потому, что он не реализован в реализации cutиз coreutils.

Тем не менее, опция -n реализована на некоторых других cutреализациях, по крайней мере, в реализации *BSD\POSIX.2 (s ).

Таким образом, cutиз coreutils реализует для него заглушку, ради переносимости, чтобы не нарушать совместимость со сценариями. Однако, поскольку он не реализован, его использование не будет иметь никакого эффекта.

Из man cutв 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.

Со страницы стандарта POSIX cut, ссылка указана @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.

3
27.01.2020, 23:22

Теги

Похожие вопросы