
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"