Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

How should I write the command variable to get the expected behavior?


function f ( )
    echo "$2"
command="f --option=\"One Two Three\" --another_option=\"Four Five Six\""

f --option="One Two Three" --another_option="Four Five Six"

First calling is wrong, second - right

$> ./ 
--another_option=Four Five Six
share|improve this question
Also appears in stackoverflow –  glenn jackman Sep 9 '11 at 13:00

1 Answer 1

up vote 7 down vote accepted

BASH FAQ entry #50: "I'm trying to put a command in a variable, but the complex cases always fail!"

TL;DR: Use an array.

command=(f --option="One Two Three" --another_option="Four Five Six")
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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