Bash: Why is echo adding extra space?
bash, echo, syntax
Solution
The easiest and cleanest solution is to add a backspace to the front of each line:
echo -e -n "\bD"{a,b,c}".jpg\n"
This produces the desired output.
Problem
I get: ``` $ echo -e "D"{a,b,c}".jpg\n" Da.jpg Db.jpg Dc.jpg ``` Note: The extra spaces before Db and Dc on the 2nd and 3rd line of the output. Why are these there? Thanks, Dan Edit: Since my actual objective had spaces in it (which I should have written originally): ``` echo -e "Name"{,.}" "{-,}"extra"{,so}" 5v5 "{one,two,No\ four}{,!,\!\!}"\n" ``` Most solutions here didn't work for me (for loop, xarg, tr). Printf didn't work because of multiple braces expansions that I want to cantesian product. I combined 3 solutions (mletterle's \b, Dennis Williamson's extra space, and Jim Dennis's using far less quotes) to get: ``` echo -e "" \\bName{,.}\ {-,}extra{,so}\ 5v5\ {one,two,No\ four}{,\!,\!\!}\\n ``` Thanks all who answered! I learned a lot from your responses! Dan