Что это за парсинг? [дубликат]

Согласно журналам, которые вы опубликовали, одна из проблем в процессе выключения связана с остановкой зашифрованного диска подкачки.

Используете ли вы зашифрованный диск подкачки? Вы недавно проверяли его монтирование, использование и размонтирование/остановку?

.
1
05.09.2017, 10:31
2 ответа

Согласноman bash:

Parameter Expansion
The `$' character introduces parameter expansion, command substitution, or arithmetic expansion. The parameter name or symbol to be expanded may be enclosed in braces, which are optional but serve to protect the variable to be expanded from characters immediately following it which could be interpreted as part of the name.

${parameter#word}
${parameter##word}
Remove matching prefix pattern.
The word is expanded to produce a pattern just as in pathname expansion. If the pattern matches the beginning of the value of parameter, then the result of the expansion is the expanded value of parameter with the shortest matching pattern (the ``#'' case) or the longest matching pattern (the ``##'' case) deleted. If parameter is @ or *, the pattern removal 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 pattern removal operation is applied to each member of the array in turn, and the expansion is the resultant list.

0
27.01.2020, 23:44

${SOME_VAR##foo/}-bashзамена переменной.

Ищет совпадение с шаблоном foo/от начала строки(SOME_VARзначения переменной )и усекает левую часть, включая шаблон.

Пример:

s="foo/some#foo#textfoo/textlast"
echo ${s##foo/}
some#foo#textfoo/textlast

Обратите внимание , этот ${s##foo/}эквивалентен ${s#foo/}, потому что он ищет только первое вхождение шаблона foo/с начала строки.

При этом ${s##*foo/}будет обрезана левая часть допоследнегосовпадающего шаблона (включительно)

echo ${s##*foo/}
textlast
1
27.01.2020, 23:44

Теги

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