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"
2

Enclose the parameter expansions in double quotes:

update_history "$greeting" "$name"
| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.