*** ADDENDUM: I use Windows10, GNUWIN32 and Cygwin64 ***
Suppose I have the following screen output:
command1
command2
command3
The desired result is each line shown above is executed as a command immediately after it is displayed on screen.
command1
command2
command2
I have read this post which explains how to insert "echo" before each line of screen output. How to apply shell command to each line of a command output? It does this:
ls -1 | xargs -L1 echo
What I have done for the time being is insert "run.bat" infront of each line. The result is the following lines are executed:
run.bat command1
run.bat command2
run.bat command3
The content of run.bat is this:
%1 %2 %3 %4 %5 %6 %7 %8 %9
It works. But this work-around seems unncessarily long.
How do I use xarg (or awk or sed) to take each line of screen output as an individual command, and run it immediately and exactly as it is displayed on screen please?
PS: I also do not want to redirect & save all screen output into a separate batchfile first, and then execute all lines that way. I would like each line of screen output to be execute exactly as a command, exactly as it is displayed and immediately after the line is displayed (I do not need to add any prefix or suffixed to the lines; just execute each line exactly as displayed on screen).
Thanks.