エスケープされたスペースを維持しながらファイルにエコーを適用しますか? [コピー]

エスケープされたスペースを維持しながらファイルにエコーを適用しますか? [コピー]

更新されていない場合、update_historyテキストファイルに次のものを含めるにはどうすればよいですか?

hello\ world john\ doe

これは$greeting $name関数やコマンドをhello\ world john\ doe


function update_history {
  history=/tmp/hist
  grep -qF "$1" "$history" \
    || (combinations=$(echo "$1" | cat - $history) \
        && echo "$combinations" > $history)
}

greeting=hello\ world
name=john\ doe

update_history "$greeting $name"

ベストアンサー1

引数拡張を二重引用符で囲みます。

update_history "$greeting" "$name"

おすすめ記事