Как Вы получаете описания доступных 'shopt' опций?

Можно сделать это с rm -i "/path/to/music/library/$(mpc -f %file% | head -n 1)". Однако предупредите, что это повредится, если имя файла будет содержать новую строку. Как вывод mpc -f %file% относительно Вашего музыкального пути к библиотеке, необходимо предварительно ожидать его к выводу.

7
29.12.2013, 01:09
2 ответа

Посмотрите "оболочку встроенные команды" раздел man bash; это имеет запись для shopt это описывает все доступные опции оболочки. Вот выборка:

   shopt [-pqsu] [-o] [optname ...]

   [...]

          autocd  If  set,  a command name that is the name of a directory
                  is executed as if it were the argument to  the  cd  com-
                  mand.  This option is only used by interactive shells.
          cdable_vars
                  If  set,  an  argument to the cd builtin command that is
                  not a directory is assumed to be the name of a  variable
                  whose value is the directory to change to.
          cdspell If set, minor errors in the spelling of a directory com-
                  ponent in a cd command will be  corrected.   The  errors
                  checked for are transposed characters, a missing charac-
                  ter, and one character too many.   If  a  correction  is
                  found,  the corrected file name is printed, and the com-
                  mand proceeds.  This option is only used by  interactive
                  shells.

          [...]
8
27.01.2020, 20:16

Можно найти список опций в странице справочника в соответствии с описанием shopt встроенный. Для открытия страницы справочника в списке опций можно использовать less функция, которая позволяет Вам выполнить команду, такую как поиск, когда она запускается:

PAGER='less "+/^ *The list of shopt"' man bash

Просмотреть эту документацию в Информации:

info --index shopt bash

Если Вы хотите извлечь соответствующую часть страницы справочника:

man bash | sed '/^ *The list of shopt/, /^ *suspend / p' | sed '$d'

или (более хороший, поскольку это удаляет добавление отступа),

man bash | awk '
    /^ *The list of shopt/ {indent=match($0, /[^ ]/)}
    /^ *suspend / && RSTART==indent {exit}
    indent {print substr($0, indent)}'

Если Вы хотите извлечь описание одной опции (например. sourcepath):

man bash | awk -v target=sourcepath '
    /^ *The list of shopt/ {shopt=1}
    shopt && $1==target {getline; indent=match($0, /[^ ]/)}
    indent {if (match($0, /[^ ]/)>=indent) print substr($0, indent); else exit}'
4
27.01.2020, 20:16

Теги

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