0

Without updating update_history how can I ensure my text file will contain:

hello\ world john\ doe

That is how can I pass $greeting $name to a function or command as 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 Answers1

2

Enclose the parameter expansions in double quotes:

update_history "$greeting" "$name"
saga
  • 1,401