When I run the next loop, I get the expected result.
for index in $(seq 1 5) ; do echo "$(date +"%Y%m%d" -d "20160301 $index day")"; done
20160302
20160303
20160304
20160305
20160306
But when I use bash edit-and-execute-command ( control- x, control- e) and enter the same loop, I get output with unexpected commands that echo repeated.
for index in $(seq 1 5) ; do echo "$(date +"%Y%m%d" -d "20160301 $index day")"; done
seq 1 5
date +"%Y%m%d" -d "20160301 $index day"
20160302
date +"%Y%m%d" -d "20160301 $index day"
20160303
date +"%Y%m%d" -d "20160301 $index day"
20160304
date +"%Y%m%d" -d "20160301 $index day"
20160305
date +"%Y%m%d" -d "20160301 $index day"
20160306
I have export EDITOR=vimin mine .bash_profile.
Update with a more complex example in response to a comment from @ l'L'l
I use sub-shells because a real team makes a fair bit bigger.
for index in $(seq 1 10) ; do td=`date +"%Y%m%d" -d "20160301 $index day"`; echo "$td: $(grep "$td" *gprs.csv | wc -l)" ; done
As with the simpler example, pasting into the command line is OK, but using the edit-and-execute-command gives a lot of echoes between them.
script ( , , ), , ( edit-and-execute -nnn 't , ).