Как делает это строчное выражение работы в ударе

Я хочу преобразовать vaiable значение в нижний регистр. Чтобы сделать это, я делаю следующее

lower_case_var=echo ${var,,}

Выше выражения хорошо работает. Однако я задаюсь вопросом это, как это работает?

-2
задан 7 January 2015 в 23:07

1 ответ

Раздел Расширение Параметра (выписка) из страницы справочника удара:

   ${parameter,,pattern}
          Case modification.   This  expansion  modifies  the  case  of
          alphabetic  characters in parameter.  The pattern is expanded
          to produce a pattern just as in pathname  expansion.   The  ^
          operator  converts  lowercase  letters  matching  pattern  to
          uppercase; the , operator converts matching uppercase letters
          to  lowercase.  The ^^ and ,, expansions convert each matched
          character in the expanded value; the ^ and , expansions match
          and  convert  only the first character in the expanded value.
          If pattern is omitted, it is treated like a ?, which  matches
          every  character.  If parameter is @ or *, the case modifica‐
          tion operation is applied to  each  positional  parameter  in
          turn,  and the expansion is the resultant list.  If parameter
          is an array variable subscripted with @ or *, the case  modi‐
          fication  operation is applied to each member of the array in
          turn, and the expansion is the resultant list.
2
ответ дан 6 October 2019 в 04:53

Другие вопросы по тегам:

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