如何在heredoc中解释一个变量而不解释另一个变量



我想解释这个heredoc的第一个变量,而不是其他两个变量。这可能吗?

cat << EOF >> "$__GREP_CACHE_FILE"
# (r) Recursively search pattern, (i) ignore case, (I) ignore binary files,
# (n) prefix with line number within file, (s) suppress error messages.
# Use path or current directory
function grepr() {
# Usage: grepr PATTERN [PATH...]
grep -rIins "$GREP_OPTIONS" '$1' '${2:-.}'
}
EOF

根据@oguzismail的评论,您可以避开其他美元符号:

cat << EOF >> "$__GREP_CACHE_FILE"
# (r) Recursively search pattern, (i) ignore case, (I) ignore binary files,
# (n) prefix with line number within file, (s) suppress error messages.
# Use path or current directory
function grepr() {
# Usage: grepr PATTERN [PATH...]
grep -rIins "$GREP_OPTIONS" '$1' '${2:-.}'
}
EOF

最新更新