I have the following brace expansion (bash shell):
echo -e {0..4..2}" "{0..2..2}"\n"
I expected this to produce
0 0
0 2
2 0
2 2
4 0
4 2
but every line of the output except the first has a leading space and there is an extra blank line at the end that I didn't expect. Why is this. Is there a simple way to fix it? Obviously I can do something clunky like pipe to sed 's/^ //'
, but is there a prettier way without piping to extra commands?
echo
doesn't do something unexpected, consider usingprintf
instead.echo
can't be unpredictable if it isn't used at all :) – chepner Jan 11 '21 at 15:54