
更新せずに、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"