I know that, given l=a b c,echo $l | xargs lsyieldsls a b cWhich construct yieldsmycommand -f a -f b -f c
xargs - append each argument with a parameter
bash;shell script;xargs
One way to do it:echo a b c | xargs printf -- '-f %s\n' | xargs mycommandThis assumes a, b, and c don't contain blanks, newlines, quotes or backslashes. :)With GNU findutil you can handle the general case, but it's slightly more complicated:echo -n a|b|c | tr \| \\0 | xargs -0 printf -- '-f\0%s\0' | xargs -0 mycommandYou can replace the | separator with some other character, that doesn't appear in a, b, or c.Edit: As @MichaelMol notes, with a very long list of arguments there is a risk of overflowing the maximum length of arguments that can be passed to mycommand.  When that happens, the last xargs will split the list and run another copy of mycommand, and there is a risk of it leaving an unterminated -f.  If you worry about that situation you could replace the last xargs -0 above by something like this:... | xargs -x -0 mycommandThis won't solve the problem, but it would abort running mycommand when the list of arguments gets too long.