-имя
принимает шелл-шаблон, а не регулярное выражение. Вам не нужно и не следует избегать .
. Просто используйте:
find ~+ -name '*.h'
Конструкция ${var:-val}
будет использовать значение по умолчанию val
, если переменная var
не установлена во время этого вызова. Это всего лишь одно из многих удобных расширений параметров. У меня есть скрипт, который сгенерирует эту полезную шпаргалку:
${V} Base string |reallyextremelylongfilename.ext
--- Default substitutions ---
${nullvar} Provided example case |
${#nullvar-def} Default value if unset or null |def
${#nullvar:-def} Default value if unset |def
--- Default assignments ---
${1} Provided example case |
${$1=def} Default value if unset or null |def
${$1:=def} Default value if unset |def
--- String metadata ---
${#V} String length |31
--- Substring extraction ---
${V:6} Substring from position |extremelylongfilename.ext
${V:6:9} Substring with length from pos. |extremely
--- Substring deletion ---
${V#*a} Delete shortest prefix match |llyextremelylongfilename.ext
${V##*a} Delete longest prefix match |me.ext
${V%e*} Delete shortest suffix match |reallyextremelylongfilename.
${V%%e*} Delete longest suffix match |r
--- Substring replacement ---
${V/long/short} Replace first match |reallyextremelyshortfilename.ext
${V/#r*a/REA} Replace prefix match |REAme.ext
${V/%.e*/.dat} Replace suffix match |reallyextremelylongfilename.dat
${V//e/II} Replace all matches |rIIallyIIxtrIImIIlylongfilIInamII.IIxt
--- Other handy things ---
${V?Message} exit 1 with 'Message' output if V is not set or is null
${V:?Message} exit 1 with 'Message' output if V is not set
${V+Value} If V is set, use 'Value', otherwise null