I'm wondering why the following prints the first command last?file=$(printf .tar.gz & printf test)echo $fileIt outputs test.tar.gz but I'd expect .tar.gztest.
Order of printf?
bash;printf
The order of asynchronous commands is not guaranteed and shall depend on the shell and operating system scheduler.A simple test (run with zsh on Mac OSX El Capital):for shell in bash ksh zsh mksh yash dash; do  printf '[%s]\n' $shell  $shell -c 'file=$(printf .tar.gz & printf test); echo $file'done[bash]test.tar.gz[ksh]test.tar.gz[zsh].tar.gztest[mksh].tar.gztest[yash]test.tar.gz[dash]test.tar.gzOn my Ubuntu 14.04 VM, all of those shells produce test.tar.gz.