I got my answer from here: Using command line history in vim
Here is a summary to execute your command of choice from command history:
q: (opens the command history window)
use vim browsing keys to go to the command you want to execute.
Alternately :n where n is line number of the command to execute, will
place you on the line.
CR -> (Carriage return) ...
What happens here is, that the bufdo and argdo command iterate over all buffers themselves. However without writing your changes, vim will refuse to load the next buffer, unless the 'hidden' option is set (which it is not by default) or the argument to the buf/arg-doc comment does write the change itself.
So this will work:
ex -s -c'bufdo! %s/\s\+$//e|w' -...
Does Ex mode have any practical use?
Probably not. However, while entering Ex mode isn't really useful, learning Ex commands still is useful, particularly because you use ex editing commands with :g/ global commands to operate on matching lines.