===== Shell ===== :date: 2020-12-26 :version: 1 .. highlight:: bash String ====== Get length:: ${#str} Substring / Slice:: ${str:1:4} Replace:: ${v%.md}.rst Prefix & Subfix:: ${foo#"$prefix"} ${foo%"$suffix"} Heredoc ------- Syntax:: cat < /tmp/foo ... Heredoc content EOF Output to variable, 使用时需要 quote 以保持原格式 ``"$VAR"``:: read -r -d '' VAR << EOF ... Heredoc content EOF .. seealso:: `How can I assign a heredoc value to a variable in Bash? - Stack Overflow `_ ``<<-EOF`` will ignore leading tabs in your heredoc, while ``<